Bug 87266 - FILEOPEN: CSV (Text Import) data type Text incorectly guessed as Numerical (Standard) while data begins with zero
Summary: FILEOPEN: CSV (Text Import) data type Text incorectly guessed as Numerical (S...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.3.4.1 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-12 14:47 UTC by jackvigier
Modified: 2016-09-19 16:48 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot import window. (53.20 KB, image/png)
2014-12-12 20:45 UTC, m_a_riosv
Details
Screenshot import window, for first option. (72.31 KB, image/png)
2015-03-23 20:04 UTC, m_a_riosv
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jackvigier 2014-12-12 14:47:03 UTC
When opening a .csv file (FILEOPEN: CSV)
the Text Import tool launches (in background... see bug ID 73751 not resolved)
every column has a data type, the standard type makes th program guess the type (theorical reminder)
when the type is text a database primary key may begin whith zero (i.e. 01234 is a text, 12345 is numeral), but the data type Text is incorectly guessed as Numerical by the Standard methid. Therefore the zeros are truncated (01234 → 1234) and if user saves the file, data is altered.
This column should be recognised as a Text data type.

Note that this bug is unherited from the original Excell, maybe because primary keys can't begin with a zero in the USA... However they do begin in with a zero around here in Europe at gouvernemental agencies, this is serious.

Thank you.

Sample dataset (.csv EOF=End of file):

pk;city;zipcode;name;
01001;L ABERGEMENT CLEMENCIAT;01400;L'Abergement-Clémenciat;
EOF
Comment 1 m_a_riosv 2014-12-12 20:45:25 UTC
Created attachment 110795 [details]
Screenshot import window.

Hi @jacvigier, thanks for reporting.

I think to resolve this situations is the option to select the column type.
Comment 2 Urmas 2014-12-13 05:14:53 UTC
If your software is broken, and thinks that 161!=00161 there is always a text column type and double quotes in the source data.
Comment 3 jackvigier 2014-12-14 14:38:46 UTC
Thank you m.a.riosv,
unfortunately, it is not optimal if I have 16 columns to force to text, or if I have many documents to open everyday. Also, there is a risk if a civil servant opens the file with the default method (or even with a Visual Basic macro), changes something not related (adds a new column... adds a new line, updates 1 figure...), then saves and exit : the zipcode (postal code) and other codes (primary key) will be altered in the csv file.
I just tried (default saving prompted when user exit LibreOffice) and here is the resulting .csv file :
pk,city,zipcode,name,population
1001,L ABERGEMENT CLEMENCIAT,1400,L'Abergement-Clémenciat,780
EOF,,,,


Thank you Urmas,
I tried with all those 3 samples and the standard method is not recognizing code as char(text) but code as number (then truncating zeros on the left) :
pk;city;zipcode;name;
"01001";L ABERGEMENT CLEMENCIAT;"01400";L'Abergement-Clémenciat;
EOF

pk;city;zipcode;name;
''01001'';L ABERGEMENT CLEMENCIAT;''01400'';L'Abergement-Clémenciat;
EOF

pk;city;zipcode;name;
'01001;L ABERGEMENT CLEMENCIAT;'01400;L'Abergement-Clémenciat;
EOF
Comment 4 Alex Thurgood 2015-01-03 17:40:29 UTC
Adding self to CC if not already on
Comment 5 Robinson Tryon (qubit) 2015-03-05 15:52:52 UTC
No dev assigned and no patches posted, so REOPENED is probably not right status. Moving back to UNCONFIRMED.
Comment 6 raal 2015-03-23 18:43:51 UTC
Hello,
see help, https://help.libreoffice.org/Common/Text_Import

Tip: If you want to include the leading zero in the data you import, in telephone numbers for example, apply the "Text" format to the column.

or

in import dialog check "Other options/Quoted fields as text" when you have this data:
pk;city;zipcode;name;
"01001";L ABERGEMENT CLEMENCIAT;"01400";L'Abergement-Clémenciat;
EOF

Closing as notabug.
Comment 7 m_a_riosv 2015-03-23 20:04:01 UTC
Created attachment 114284 [details]
Screenshot import window, for first option.

For 1/3 sample data in comment #3, seems to work fine with the options showed in the attached screenshot.
Comment 8 Robinson Tryon (qubit) 2015-12-18 10:36:54 UTC Comment hidden (obsolete)
Comment 9 Xisco Faulí 2016-09-19 16:48:03 UTC Comment hidden (obsolete)