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).
Related
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 ".
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 have a column that has values stored as text:
'1002079943728939269'
I want to store it as int64 format, so that last digits are not lost. If I remove the quotes, the value displays as 1.00208E+18. The digits after 100207994372893 become 0.
How can I have a numeric format with support for long integer values?
Excel uses a 64-bit floating point representation for numbers entered in cells, which means you can only have 15 digits precision.
In comments you explained you actually need to produce a CSV file with these large numbers, which represent ID values.
Then the solution is to enter the numbers as text. There are two ways to do this:
Prefix the value with a single quote, but don't end them with single quote: once you have entered the value like that, the quote is not displayed in the cell, or
First format the cell as Text instead of General (via the ribbon) and then enter the number: the number will not automatically be converted to the number data type any more, but stay like text.
When you then save the document as CSV, open the CSV file in a text editor. You will see that the numbers appear as they should be: without the single quote, but also not wrapped in double quotes.
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: