How to change delimiter semicolon to comma of a file in google sheets or other way? I have already tried text to column feature but my file is too large around 10 MB so it doesn't work.
I have been through that path quite a few times, since business logic likes to use Excel, and software likes CSV.
Excel, and probably Google Sheets etc, are a pain to use for CSV. Especially Excel because it tries to be "friendly" for you, so it typically exports with separators determined by the Windows Locale (ex: ";" or "," ) - and excel usually shifts between quotes and no quotes.
If you HAVE the text file, and wish to IMPORT into excel, find the combination of separators that suits your language variant, using a test file. To convert the big text file, a tool like AWK is simple and awesome.
To EXPORT from Excel, I would again just go with whatever Excel wants to do, then adapt the file after using AWK or similar. Easier for me than trying to find settings for separator and quoting.
There is an article here that I find helpful.
PS: I should mention that in most of European region, CSV IS semicolon by default.
I need to export an Excel file as CSV to import into a database. I cannot use commas because there are commas in some text fields. Things I have tried that did not work well:
Changing commas in text to periods. This works, but not great.
Change Control Panel settings and changing "List separator" settings to a pipe. This also works, but then I have to use pipe in formulas in Excel, which is not great.
Are there any other options?
Using commas works fine. Commas that exist in text are not considered as separators when exporting from Excel into CSV because they are wrapped in quotes. All database import utilities should account for this by now.
If you don't have commas in your text:
1,2,3,4,this is text
If you do have commas in your text:
1,2,3,4,"this, is text"
CSV imports won't consider commas as delimiters that are wrapped in text.
You can use TEXTJOIN formula of Excel to concatenate all columns you want with a specific delimiter like the pipe.
Example for the columns below:
you can use the formula like below, one for each row above:
=TEXTJOIN("|",FALSE,A1,B1,C1,D1)
=TEXTJOIN("|",FALSE,A2,B2,C2,D2)
The result will be:
Finally, you can save this result as a text file.
You should enclose all fields with quotes:
"value 1","value,2","value3"
I am downloading .csv files in remote server. It is taking the thousand separator as . instead of ,. How I can rectify this?
First, I would suggest looking at these two questions that have already been answered:
How to read data when some numbers contain commas as thousand separator?
Dealing with commas in a CSV file
I am not sure what you are doing with the exported file, but another option would be to remove the "thousand separator" on the file before exporting it as csv, then reformatting it after you have performed your action.
I'm having problem with finding a unique delimiter for excel when I import a bunch of data from csv. I wanted "^;" to be the unique delimiter. However, Excel isn't smart enough to know that I just want "^;" as delimiter NOT IN CONJUNCTION with single "^" and/or single ";" even I checked both "Semicolon" and "Other" (i.e. ^) as well as selecting "Tread consecutive delimiters as one". Is there any way to achieve that in Excel where "^;" will be the only unique delimiter it has to look for. Or it's just a painful reality we need accept in MS Excel?
Openoffice allows you to specify the separation string when saving your file as .csv.
As far as I know there is no way of having a multi character delimiter when importing with Excel.
If it's possible with your dataset, I suggest using find and replace to change all instances of "^;" to a more common delimiter format. Having done this you should be able to import into Excel easily.
I want to generate a CSV file for user to use Excel to open it.
If I want to escape the comma in values, I can write it as "640,480".
If I want to keep the leading zeros, I can use ="001234".
But if I want to keep both comma and leading zeros in the value, writing as ="001,002" will be splitted as two columns. It seems no solution to express the correct data.
Is there any way to express 001, 002 in CSV for Excel?
Kent Fredric's answer contains the solution:
"=""001,002"""
(I'm bothering to post this as a separate answer because it's not clear from Kent's answer that it is a valid Excel solution.)
Put a prefix String on your data:
"N001,002","N002,003"
( As long as that prefix is not an E )
That notation ( In OpenOffice at least) above parses as a total of 2 columns with the N001,002 bytes correctly stored.
CSV Specification says that , is permitted inside quote strings.
Also, A warning from experience: make sure you do this with phone numbers too. Excel will otherwise interpret phone numbers as a floating point number and save them in scientific notation :/ , and 1.800E10 is not a really good phone number.
In OpenOffice, this RawCSV chunk also decodes as expected:
"=""001,002""","=""002,004"""
ie:
$rawdata = '001,002';
$equation = "=\"$rawdata\"";
$escaped = str_replace('"','""',$equation);
$csv_chunk = "\"$escaped\"" ;
Do
"""001,002"""
I found this out by typing "001,002" and then doing save-as CSV in Excel. If this isn't exactly what you want (you don't want quotes), this might be a good way for you to find what you want.
Another option might be use tab-delimited text, if this is an option for you.
A reader of my blog found a solution, ="001" & CHAR(44) & "002", it seems workable on my machine!
Pretty old thread but why don't you just add whitespace after your value. It will be then treated as string and no leading zeros will be stripped.
"001,002"." "
Since no-one mentioned it already, figured it was worth mentioning it in this old post.
If you add a horizontal tab character \t before the number, then MS Excel will also show the leading zero's. And the tab character doesn't show in the excel sheet. Even if it's surrounded by double-quotes. (F.e. \"\t001,002\")
It also looks nicer in Notepad++, compared to putting a \0 aka NULL before such number.
Looking more at the Excel spreadsheet it looks what you want can't be done using CSV.
This site http://office.microsoft.com/en-us/excel/HP052002731033.aspx says "If cells display formulas instead of formula values, the formulas are converted as text. All formatting, graphics, objects, and other worksheet contents are lost. The euro symbol will be converted to a question mark."
However, you can change how you load it to get the result you want. See this web page:
Microsoft import a text file.
The key thing is to choose Import External Data-Import Data-Text Files, go Next, Next, and then tick "Text" under column data format. This will prevent it being interpreted as a number, and losing formatting.
I was fiddling around with CSV to Excel (i use PHP to create the CSV, but i guess this solution works for any language. When you spot that a leading characters (such as + , - or 0 are disappearing, create the CSV with chr(13) as a prefix. This is a non printable character and it works wonders for my Excel Office 2010 version. I tried other non printable characters, but with no luck.
so i use Chirp Internet solution but tweaked with my prefix:
if (preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) {
$str = chr(13)."$str";
}
If you are using "Content-Disposition" and exporting from asp to excel using HTML tags,then you have to add "style='mso-number-format:\#;'" to that tag and making it to accept only Text values ,thereby leading zeroes omission will be avoided,If Forward slash"\" is accepted use double forward slash "\"
All the suggested answers don't seem to work for me right now ("=""blahblah""" and others) in all current Excel versions or Numbers app on OS X.
The only solution I found to be working by fiddling around is to add an escaped null character at the beginning of the string (which is \0 in PHP or C based languages). Everything ends up treated as is without being calculated or processed by the software when opening the calc sheet.
echo "\0" . $data;
Excel uses a default formatting for CSV columns depending on the content. So if you have 001 in a csv, excel will automatically turn it to 1.
The only way to keep the leading zeros in excel from a csv file is by changing the extension of the csv file to .txt, then just open excel, click on open, select the txt file, and you'll see the Text Import Wizard. Select your csv format (separated by commas), then just make sure you select "Text" as the format.
And that's it, now you can export that previous csv data to any other while keeping the leading zeros.
This is straightforward using Excel's Power Query functionality that allows you to perform step-by-step transformations.
Original File:
Add a Custom Column: