------------------------------------------------------------------------------ -- File: CSV2XLS.adb -- Description: Converts a CSV (text with Comma Separated Values) input -- into an Excel file. You can specify the separator. -- E.g. If you open in Excel a CSV with semicolons as -- separators on a PC with comma being the separator, -- and then apply "Text to columns", the eventual commas in -- the text will already have been used as separators and -- you will end up with a total mess. CSV2XLS prevents this -- issue. -- Syntax: csv2xls {option} separator := ','; when 's' => separator := ';'; when 't' => separator := ASCII.HT; when 'f' => Freeze_Top_Row (xl); when others => null; end case; end if; end loop; -- -- Process the CSV file -- while not End_Of_File loop declare line : constant String := Get_Line; bds : constant CSV.Fields_Bounds := CSV.Get_Bounds (line, separator); begin if first then first := False; end if; for i in bds'Range loop Put (xl, Ada.Strings.Fixed.Trim (CSV.Extract (line, bds, i), Both)); end loop; end; New_Line (xl); end loop; Close (xl); if Is_Open (input) then Close (input); end if; end CSV2XLS;