I have a CSV file stored in UTF8 encoding, with fields delimited by commas, and text (and date) fields enclosed in double-quotes, like this:
12345,"First row column 2","2021-05-12", "First row column 4","£100"
67890,"Second row column 2","2021-05-11", "Second row column 4","£200"
When I open this file in Excel365, the double-quotes are retained instead of being discarded as delimiters as I would expect. I cannot find any CSV import filter options (including in the Get Data From Text/CSV feature) which allow me to remove the double-quotes - which were only added in the first place to identify the column as text in the CSV file.
Can anyone provide help with removing the quotes automatically during the import process, or guidance on how to create a CSV file with delimiters that Excel will treat sensibly?
There is a space between the separator and the first quote of the fourth column:
12345,"First row column 2","2021-05-12", "First row column 4","£100"
67890,"Second row column 2","2021-05-11", "Second row column 4","£200"
Most likely that is causing the problem (if that is also the case in your original data).
which were only added in the first place to identify the column as
text in the CSV file.
Quotes are not used to identify a column as text (in csv all columns are text and it is up to the appllication how to treat the data), but to allow possible separators inside the fields, like:
1234,"aaa,bbb"
So if you don't have separators inside the fields you don't need the quotes.
This works for me:
Open the CSV-File with an Editor. Copy everything into a new Excel-Sheet (Column A for example). Then select column A and use Data -> Text to Column. Selected Fixed -> next. Choose Comma as a delimiter and set the textqualifier to ".
Related
I downloaded the csv version of the table present in this web-page https://d-place.org/parameters/DistToCoast_km#1/30/152. In the online version of the table the first column looks like this:
0.046161698
0.046405053
0.102112618
0.102112618
2,047.307804
2,029.644235
but when I open the csv file in Excel, these values look like this:
46161698
46405053
102112618
102112618
2047307804
2029644235
Can anyone tell me how to get a file usable in Excel in which first column values are the same of the first column online version and also look the same?
you have to separate spaces with commas,
like column1,column2,column3
in your case i assume you have only 1 column like this
value1
value2
...
value n
in between the value you should not put any comma, otherwise it will be interpreted as a new column.
and your error was also that you didnt formatted excel sheets to display decimal numbers, so it cut out the zeros.
you have 2 ways:
you should format cells as text
format cells as decimal numbers
I opened the csv file directly clicking on it, without opening Excel before and clicking on Data > From text and importing the file. After opening the csv file clicking on it, Excel starts and the spreadsheet looks like this:
The I click on Data > Text to Columns > Delimiters: Comma, then I specify in the advanced settings that Decimal separator is ".", while Thousands separator is ",". After this passages, spreadsheet looks like this:
I need to export a Excel sheet to cdv (easy) but I need to have this format for numbers:
102.682,35
and my csv file is doing this:
3928.5400000000027
I need to have thousands quote separator.
any idea?
Two things here. If the CSV will be imported back into an Excel spreadsheet, then having a comma as a thousands separator is a visual format issue. This means that it can be formatted to show the thousands comma once it's back in Excel. In this case, don't worry about adding a thousands comma to the CSV file, just make sure to format the cells later.
Secondly, if you really do need a thousands comma in the CSV file you can do this yourself with VBA by learning how to create a loop over your data range and write to a text file in the CSV format. Now the thing about CSV is that the "separator" doesn't have to be a "comma" (even though CSV means "comma separated values"). You can choose any character that won't be used within any value.
Typically you'd do this if a comma is likely to appear in a value such as a string:
This is a sentence, but it has a comma embedded within it.
In your case you want a comma in a number value 133,491.234. So for the separator in a CSV file, choose another character such as the vertical pipe |. Now the values in the CSV file would look like this:
Doctor|Smith, John|$142,533|Brown Eyes
Look at this website to learn to Write Data to Text File and when you're looping over the cell values and come to the value that needs the thousands comma, use the Format function similar to this:
Format(cellValue, "#,##0.00")
I'v got the following data in Excel which I export to CSV. However, as you can see in text editor, the "Mval" values are often encapsulated by quotes. I assume this is because in Excel the number formatting has a "," separating the thousands.
Is there any way to export the data above as CSV without Excel wrongly recognizing numeric values as text (despite their number formatting)?
Having a field quoted in csv does not mean that the value is of type string (csv has no types).
The quotes are there because there is a comma in the field, and this is the way it should be. Any csv reader should read the data fine.
If you want to keep the number format as it is now (including the comma) and really don't want quotes, you can try to change the delimiter to ; (or tab).
I have an excel spreadsheet that has two columns. When I choose to save it as a csv file, the comma after the second column is not in place. For example, i get this:
Invoice,SID No.
156106,ELC204R8
156106,WXC2048V
Instead of this:
Invoice,SID No.,
156106,ELC204R8,
156106,WXC2048V,
How to I get the comma in right before the line break?
This as I assume you are aware is not a usual requirement/format for saved CSV file.
To achieve what you are trying to do though, you need to trick Excel into thinking you are exporting a third blank/empty column.
One way to do this is to add the single-quote character ' into a third Excel column before exporting.
I just entered a space into the first 20 rows and that solved the issue.
So I am working on prepping my data for insertion into a sqlite db. Historically, I have put it into excel, and the data in different cells has equated to different rows in my db table (through csv importation).
So now I have a huge bit of text that I have pulled from a webpage which is just in one cell, but I need to break the text up into different cells. How can I insert a carriage return? Or is there a way I can send the data into excel with a symbol that will automatically put it into separate cells? Or could I possibly make my own custom csv file? Aside from cutting the text I want to move, is there a more efficient way?
There are numbers that are in the text that are unique and increasing that I could use to insert something, but I can't figure out how to do it.
Please help!
A 10 step solution…
Select the cell with the huge text:
Insert your delimiter character (e.g. I chose '#') anywhere you wish:
Replace hard returns by your delimiter character:
You can also choose to do the latter with a formula:
=SUBSTITUTE(A1," <— insert ALT+ENTER here for a hard return between the quotes
","#")
This way you will not accidentally skip any hard returns (the conversion wizard chokes on them).
Start the Text to Columns conversion wizard for the selected cell:
Choose delimited:
Choose delimiter:
Copy the resulting range of cells in order to transpose them:
Choose Paste Special on the starting cell for pasting the transposed range:
Select Transpose…
DONE!
Instead of working in Excel, you can also manipulate the CSV file. Just respect the CSV basics and you should be able to (experiment a little and then) get the job done:
A CSV file holds Comma-Separated Values, in a delimited data format that has fields/columns separated by the comma character and records/rows terminated by newlines.
Fields that contain a special character (comma, newline, or double quote), must be enclosed in double quotes, after doubling any existing double quotes (to escape those).
So if you take a look a the huge cell in CSV format (just use any plain text editor), it probably spans several lines and is enclosed in double quotes, like this?
You can split up that one quoted multiline text into e.g. several quote single lines of text, such as shown below: