Thank you!
(I have no idea what a "literal comma" is - Have never heard about this)
My
function()
1) Will clear empty rows / fields.
Empty rows / fields also include e.g.
"", "", "" ,, "" (maybe even
" ","","" ,,,)
2) Analyzes which fields will have problems after a change of field dividers (and possibly handle these)
for example
37,56 ; 45,75 ; 90 ; 9,90 (is not the same as
37,56 , 45,75 , 90 , 9,90 (after the delimiter is changed to
, )
3) Manage the lines that will have problems with a conversion
Right now can I not handle an uneven number of quotes.
e.g.
; Diff"icult;""; 98 456;perhaps impossible to handle?
4) If the field contains control characters or similar - delete all this characters? (these are not handled - right now)
So far - the function() to read the CSV-file (and analyze any problems)
If the number of fields differs from e.g. first line (usually the header line), these should probably be moved to a log file.
In my case I will do this after the CSV file is cleaned from unwanted rows
Your program doesn't give the same result as mine.
Assume the CSV information below (I hope it appears in the same way as I want)
All rows contain 5 fields (if I counted correctly)
Code: Select all
(
"abc def"; "0,02" ; "0,03"; "0,04" ; "0,05"
"";"" ;""; "" ;""
"";" " ;""; "" ;""
10; 17,90 ; 15,30; 4,50; "700; 32"
"bla";"bla";"bla "bla" bla";;
"bla";"bla";"bla ""bla"" bla";;
"";"";"";;
pensé; abc åäö;; 12345;
"first field";SecondField;"the word ""special"" is quoted literally";;"last field, has literal comma"ß
; Diff"icult;""; 98 456;perhaps impossible to handle?
;,;,;,;,
"0,001"; "0,002"; "0,003"; "0,004"; "0,005"
)
The input and result from my program .:
"abc def"; "0,02" ; "0,03"; "0,04" ; "0,05"
"";"" ;""; "" ;""
"";" " ;""; "" ;""
10; 17,90 ; 15,30; 4,50; "700; 32"
"bla";"bla";"bla "bla" bla";;
"bla";"bla";"bla ""bla"" bla";;
"";"";"";;
pensé; abc åäö;; 12345;
"first field";SecondField;"the word ""special"" is quoted literally";;"last field, has literal comma"ß
; Diff"icult;""; 98 456;perhaps impossible to handle?
;,;,;,;,
"0,001"; "0,002"; "0,003"; "0,004"; "0,005"
k .: 1 v .: "abc def","0,02","0,03","0,04","0,05"
k .: 2 v .: 10,"17,90","15,30","4,50","700; 32"
k .: 3 v .: "bla","bla","bla "bla" bla",,
k .: 4 v .: "bla","bla","bla ""bla"" bla",,
k .: 5 v .: pensé,abc åäö,,12345,
k .: 6 v .: "first field",SecondField,"the word ""special"" is quoted literally",,"last field, has literal comma"ß
k .: 7 v .: ,",",",",",",","
k .: 8 v .: "0,001","0,002","0,003","0,004","0,005"