Bug 127062 - Importing a CSV with "0123" as a value removes the leading 0
Summary: Importing a CSV with "0123" as a value removes the leading 0
Status: CLOSED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-20 23:17 UTC by Ben
Modified: 2019-08-21 01:20 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Example file where 0123 becomes 123 (13 bytes, text/csv)
2019-08-20 23:17 UTC, Ben
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben 2019-08-20 23:17:49 UTC
Created attachment 153541 [details]
Example file where 0123 becomes 123

I have attached an example CSV file that demonstrates this issue.

When importing the CSV the value "0123" shows in the preview as 0123 but after clicking OK and viewing the new spreadsheet in Calc both A1 and B1 are set as 123 and the leading 0 is removed.

This causes phone numbers from an export to load without their leading digits and become invalid.

Tested on the 6.3.0.4 and 6.0.7.3 releases on Ubuntu 18.04.
Comment 1 m_a_riosv 2019-08-21 00:13:11 UTC
You can click on the head of the column and select Text as type.

https://help.libreoffice.org/6.3/en-US/text/scalc/guide/csv_files.html?DbPAR=CALC#bm_id892361

Please do your questions in Ask.libreoffice.org
Comment 2 Ben 2019-08-21 00:22:46 UTC
That is a workaround but I think that if the value is wrapped in a string delimiter then it should be treated like a string and preserved (and if not, it can be treated like a number).

In this example 0123,"0123" would import as 123,0123

Other cases like "0/10" will preserve the 0 and this feels inconsistent.
Comment 3 m_a_riosv 2019-08-21 01:03:46 UTC
Please attach a sample with a couple of lines.

Do you see in the import window "Format quoted field as Text"
Comment 4 Ben 2019-08-21 01:20:17 UTC
Thanks m.a.riosv :) "Format quoted field as text" creates the behaviour I was after. Not sure how I missed that.