Dot at end of numbers in CSV file - excel

I have an excel file with some numbers followed by a dot, say:
12345.
I created a simple macro to convert and save the excel file into a .csv file.
The problem is the CSV file does not save the dot. The data comes out as 12345 and not 12345. I also tried manually adding the dot and saving the csv file, but the dot just dissappears.
Anyway to add the dot into the CSV file?
http://i.stack.imgur.com/UoboK.jpg

Add a single quote/apostrophe in front of the number (without a closing quote at the end), so that it reads it as text and does not auto-format it as number.
For example you have:
12345.
Excel will auto-format that column as a number and drop the period unless you specify that it's a text only column.
Change it to:
'12345.
Excel will read that value as a text column and will not save the apostrophe in a text-based CSV file.
Edit:
In testing this, I found that ff you save it as "12345.", Excel changes the CSV file to """12345.""".

Related

How do I export an Excel data sheet to a .txt file as Delimiter colon?

I have a .txt file that was given to me (exported from a database) that includes columns and rows. I was told some of data was in the wrong column. I just needed to move it to the next column over. I opened the .txt file in Excel using the Data "From Text/CSV" option and made my changes. Once I was finished, I saved my file as a .txt file like it was given to me, however it's not in the same format. My .txt export kept the column and rows whereas the original file given to me had the information had the values separated with "|" characters. Do you know how I can get the data in the "|" format so I can send it back to them? See my screenshots for reference.enter image description here
Once you have opened the file in Excel and made your changes, you can use the steps in below link here to change the delimiter to "|" or anything else you would like...

how to denote an end of line character in excel so csv file doesn't contain extra delimiters

I am trying to create a CSV file off an excel file. the problem is, whenever I create the CSV file, it treats every cell in the header/trailer as a cell with information in it.
What do i do to prevent those extra trailing , (commas) in the csv?
Sample excel file:
Here is what the delimited file looks like. I don't want all those extra commas.
td,sd,HDR,020321,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
20210130,20210202,2610081743,2610081743,PSHG,2610081743,,,C,595017BH7,PB 1234
20210130,20210202,2612230531,2612230531,PSHG,2612230531,,,C,02156BEE5,PB 45657
20210130,20210202,3101140730,3101140730,PSHG,3101140730,,,S,EXGA,PB 8910
20210130,20210202,3210231839,3210231839,PSHG,3210231839,,,S,SITP,PB 1111
20210130,20210202,3210231935,3210231935,PSHG,3210231935,,,S,EU000A285,PB 2222
,,TLR,5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Generating CSV data with slashes and semicolons to be imported with Excel

Is it possible to prepare a CSV file with the single value 1/4;5, such that it can successfully be imported with Excel?
This I what I would like to get:
I created a small CSV file with the following contents:
1/4;5
=1/4;5
="1/4;5"
"=""1/4;5"
If I open the document with Excel 2016 (German version), I get:
On my system, all I need to do is surround the desired phrase with the text qualifier. Again, on my system that is the double quote "
So with CSV containing "1/4;5", if I OPEN the .csv file, it will show 1/4;5 in the worksheet cell.
It will be a text string with a numberformat of General

Automatically convert csv file into Excel table?

I generate some csv files using a script. Next I manually convert those csv files into excel tables using the import wizard in excel based on:
https://www.youtube.com/watch?v=z5Pxil4jVO4
Is it possible to do this automatically - e.g. by calling an excel importer from command line - so I don't need to open excel and do all the manual work?
I can open the csv file directly in Excel but its not formatted as a table. E.g. this csv file:
a,b,c
a,b,c
results in this Excel sheet:
I would like each letter to be in a separate column.
I have looked at this:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/370ee470-f2cd-4f30-a167-b106dd51d47a/powershell-convert-csv-to-xlsx?forum=winserverpowershell
but its an awful lot of boiler plate code from create a simple table.
Add an extra line to your CSV file to tell Excel what the seperator is. Add the following line to the top of your CSV file:
sep=,
The easiest way, without close and edit your file - you can choose which separator you want in Excel 2010-2016 go to DATA, Text To Columns, choose Delimited, then choose your separator Comma (or other) and you will see changes immediately in the "Data preview", then click FInish.
Once you have the format you wanted, you simply save the document and it will be permanent.

Number format in CSV file

I've got a macro that imports data from a SQL db to excel then saves the results as a CSV file. When it saves to CSV the formatting of two of the columns is lost, resulting in the numbers not displaying correctly.
Column 1 contains 12 digit numbers such as '800000000000' which are showing in the CSV file as '8E+11'
Column 2 contains 10 digit numbers such as '4880000000' which are showing in the CSV file as '4.88E+09'
The data displays fine when it is first imported to excel, the problem occurs when saving to CSV, although when I expand column 2 in the CSV file it displays the full number. This doesn't work for column 1 though, I have to change the formatting of the cell.
I usually run the macro then send the created CSV file on to a colleague, is there a way I can keep the number formatting without having to open and edit the CSV file?
Thanks
Adding "=" before the quotes preserves the pattern
For Example if your csv file is like
A1,col1,col2,col3,="001"
The 5th column will still be 001 when opened in excel

Resources