Exporting long numbers to CSV file for Excel - sql

This is perhaps one of those many times discussed questions with solutions more specific to actual system that outputs the data into a CSV file.
Is there a simple way to export data like 3332401187555, 9992401187000 into a CSV file in a way that later when opened in Excel, the columns won't show them in "scientific" format? Should this be important, the data is retrieved directly by an SQL SELECT statement from any DBMS.
This also means that I've tried solutions like surrounding the values with apostrophes '3332401187555' and the Excel cell recognizes those as text and doesn't do any conversions/masking. Was wondering if there was a more elegant way without actually it being a pre-set Excel template with text data fields.

1. Try exporting the numbers prefixed with single quote. Example: '3332401187555.
2. In excel, select the column containing number values
and then select Number in Format Cells.

Just have to save your file with Excel the option CSV file. And you have the in file in requested format.

Related

How to automatically convert text-based numbers to numbers in several files?

I have 1000 files in Excel format (Excel 2010) and each file contains 7 sheets with data.
This is an example for Excel sheet.
Is there a way to automatically convert the numbers that are stored as text to numbers, without affecting the actual text data? (maybe by VBA macros ? but I am a beginner in VBA code)
I can give you an algorithm, but I don't have time to write the entire code. I would write it in a seperate workbook, for repeatability. You can then either hardcode the 7 file names, or you can make an input for file name (the latter is a bit more flexible, if you need to use it for more files later).
Open a file
Loop all sheets
Loop all cells
If IsNumeric(Cell.Value) > Change format
You should be able to Google your way to the separate parts. Once you have some actual code, you can ask for more help on StackOverflow.

Import a CSV file into Access using VBA

I need to use VBA to import a large CSV excel file into an Access table. The delimiter is "" (double quotes) except for some reason the first value is followed by " (only one quote) instead of two like every other value. The first row contains the column headers and are delimited the same way. At the bottom I have attached an example.
The CSV files are generated automatically by an accounting system daily so I cannot change the format. They are also quite large (150,000+ lines, many columns). I'm fairly new to VBA, so as much detail as is possible would be much appreciated.
Thanks in advance!
Example of format
That doesn't sound like a CSV file. Can you open it in Excel, convert it to a true CSV, and then import that into Access? You will find many VBA-driven import options at the URL below.
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm
Also, take a look at these URLs.
http://www.erlandsendata.no/english/index.php?d=envbadacimportado
http://www.erlandsendata.no/english/index.php?d=envbadacimportdao

How to convert Excel data into MySQL query format

I have bulk of data in an Excel sheet and I saved it into .csv format like this:
101,shortname,null,Description
My question is how to place single quotes for text data like
101,'shortname',null,'description'
?
101,shortname,null,Description
1) Is this in the single cell or different cells in excel?
2) Do you want to update the excel sheet or just want to put that data in mysql?
If you want to take data from excel and put it into mysql you can use apache-poi libraries.
apache-poi
I used this library to update the excel sheet from mysql database.
Get an editor capable of doing search/replace with regular expressions
Write a regular expression that will update the text the way you want it to
Here's an example how to do what you ask in Visual Studio's text editor:
Find what:
{[^,]+},{[^,]+},{[^,]+},{[^,]+}
Replace with:
\1,'\2',\3,'\4'
If you have some other editor, go check its documentation on regular expressions.
For VIM check out vimregex.com, something like this might work:
s:\([^,]\+\),\([^,]\+\),\([^,]\+\),\([^,]\+\):\1,'\2',\3,'\4':
so you want your csv data to add a single quote and restore in the same file? I this is so, simply copy/cut that column in some other column and use an excel formula like suppose you have your shortname in column B cut-paste it to column Z and use formula =CONCATENATE("'",Z#,"'") # is the row number

Need help with VB app to compare data in various text files

I'm new to visual basic and have been tasked with creating an app that will read in various text files(.csv, .txt) and compare some of the data contained within.
I thought I would read in the files and convert them to datatables. Once I had them in a datatable I figured I could remove the unnecessary rows/columns and then sort and compare the pertinent info for differences. The difficulty is that the various files are formatted differently so I will need to get each type formatted correctly. Is this the best approach?
If so, I need help with the datatables. I have read in a .csv, parsed it into a datatable, but I'm having trouble with the logic/coding to get rid of the rows and columns that I don't need. Also, I'm not sure how to handle a row that has a cell with a comma seperated list of values that will need to be split into individual rows.
Thank you.
There are lots of ways to accomplish this. One way:
Read each file, then convert it to a string array in a common format, such as csv. For each file, you can handle the issues of field location, field format, and multiple rows, and convert it to the common format. After you have the files in a consistent format, you can move them to a data table for sorting, comparison, etc.

How do you set the "global delimiter" in Excel using VBA?

I've noticed that if I use the text-to-columns feature with comma as the delimiter, any comma-delimited data I paste into Excel after that will be automatically split into columns.
This makes me think Excel must have some kind of global delimiter.
If this is true, how would I set this global delimiter using Excel VBA? Is it possible to do this directly, or do I need to "trick" Excel by doing a text-to-columns on some junk data, then delete the data?
My ultimate goal is to be able to paste in a bunch of data from different files using a macro, and have Excel automatically split it into columns according to the delimiter I set.
Junk data is the right answer. See here
http://spreadsheetpage.com/index.php/tip/clearing_the_text_to_columns_parameters