ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   CSV and Numeric Strings with Leading Zeros (https://www.excelbanter.com/excel-worksheet-functions/177477-csv-numeric-strings-leading-zeros.html)

Ed Ardzinski

CSV and Numeric Strings with Leading Zeros
 
I am trying to deliver a report in CSV format, which admittedly is not my
favorite text format. There is a field that is a numeric string,
occasionally having leading zeros, which is causing an issue.

I am getting my data out of a SQL Server query (not that it matters a lot)
and I initially tried to enclose allt he text fields in double quotes.
Opening the CSV in Excel resulted in the double quotes not being visible, but
the numeric string field still suffered from the dropped leading zeros.

I then tried to add a single quote in that field, first after the double
quote (now the whole numeric string is displayed with the leading zeros, but
ALSO with the single quote), then with the single quote before the double
quotes (now the string appears enclosed in the double quotes when opened in
Excel)...tried just a single single quote before the field, and still no dice.

I tried to copy the data from SQL Server and paste in an Excel sheet with
the column formatted to test, then saving as a CSV. Same problem - open the
CSV and the leading zeros from this field are stripped.

Any insight ont his would be appreciated. Thanks!

Beege

CSV and Numeric Strings with Leading Zeros
 
Ed Ardzinski wrote:
I am trying to deliver a report in CSV format, which admittedly is not my
favorite text format. There is a field that is a numeric string,
occasionally having leading zeros, which is causing an issue.

I am getting my data out of a SQL Server query (not that it matters a lot)
and I initially tried to enclose allt he text fields in double quotes.
Opening the CSV in Excel resulted in the double quotes not being visible, but
the numeric string field still suffered from the dropped leading zeros.

I then tried to add a single quote in that field, first after the double
quote (now the whole numeric string is displayed with the leading zeros, but
ALSO with the single quote), then with the single quote before the double
quotes (now the string appears enclosed in the double quotes when opened in
Excel)...tried just a single single quote before the field, and still no dice.

I tried to copy the data from SQL Server and paste in an Excel sheet with
the column formatted to test, then saving as a CSV. Same problem - open the
CSV and the leading zeros from this field are stripped.

Any insight ont his would be appreciated. Thanks!



Ed,

You can rename a .CSV to .TXT and import that. It will give you the
option of formating those numbers as text, preserving the leading zeroes.

Beege

Ed Ardzinski

CSV and Numeric Strings with Leading Zeros
 
Ed,

You can rename a .CSV to .TXT and import that. It will give you the
option of formating those numbers as text, preserving the leading zeroes.

Beege


I could do that, but the file is supposed to be sent to someone else to load
into a batch process. I'm not sure the recipient would be happy to have an
extra step in their process.


All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com