https://bugs.documentfoundation.org/show_bug.cgi?id=94469
Peter Rich <pr...@earthling.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|File function Input error |Calc Macro File function | |Input error --- Comment #1 from Peter Rich <pr...@earthling.net> --- Problem with File Reading in LibreOffice Macros. I am trying to read a text file (output from a LibreOffice spreadsheet as a csv file) and create a new text file containing counts of specific records in the source file. I continually get garbage in the destination file. In an attempt to determine the cause of the garbage I altered the macro to write the input variables back (without alteration) to a new temporary file. A sample from the input file is set out below: =============================================================== 19/10/2010,07:39,162,82,67,,,n,n,n,,,,1,0, 23/10/2010,07:37,175,87,61,,,n,n,n,,,,1,0, 24/10/2010,07:13,148,83,70,,,n,n,n,,,,1,0, 26/10/2010,07:22,146,84,73,,,n,n,n,,,,1,0, 27/10/2010,07:26,181,86,68,,,n,n,n,,,,1,0, 29/10/2010,07:41,165,82,68,,,n,n,n,,,,1,0, =============================================================== The new file created by writing the input straight back to a temporary file is set out below. I have removed the quotation marks (") to make the output narrower =============================================================== 19/10/2010,07:39,162,82,67,,,n,n,n,,,,1,0,23/10/2010 07:37,175,87,61,0,,n,n,n,,,,1,0,24/10/2010,07:13 148,83,70,0,0,n,n,n,,,,1,0,26/10/2010,07:22,146 84,73,0,0,n,n,n,,,,1,0,27/10/2010,07:26,181,86 68,0,0,n,n,n,,,,1,0,29/10/2010,07:41,165,82,68 0,0,n,n,n,,,,1,0,30/10/2010,07:54,172,88,66,0 =============================================================== Each of these files have 16 'fields' per line but obviously the Spreadsheet save as csv function and the macro Input function do not understand each other. Immediately after the trailing comma (,) in the input file is a linefeed (0A) The LibreOffice help for the Input function states (in part): =============================================================== The Input# statement reads numeric values or strings from an open file and assigns the data to one or more variables. A numeric variable is read up to the first carriage return (Asc=13), line feed (Asc=10), space, or comma. String variables are read to up to the first carriage return (Asc=13), line feed (Asc=10), or comma. Data and data types in the opened file must appear in the same order as the variables that are passed in the var parameter. If you assign non-numeric values to a numeric variable, var is assigned a value of 0. =============================================================== Clearly, this does not occur where the expected string consists ONLY of a line feed (0A). The only work around I could find was to ignore the sixteenth 'field' when reading the file. -- You are receiving this mail because: You are the assignee for the bug.
_______________________________________________ Libreoffice-bugs mailing list Libreoffice-bugs@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs