Recent

Author Topic: Need help to Create .CSV file using Pascal Lazarus  (Read 582 times)

RaviMore9

  • New member
  • *
  • Posts: 9
Need help to Create .CSV file using Pascal Lazarus
« on: October 11, 2022, 02:34:49 pm »
Hello ,

 I need the help to create CSV file using Lazarus(Pascal).
Please find the attached file for reference.
File details
1. Read the data buffer where data is already available
2. Separate out data from buffer and add into .csv file

System details are as follows:
1. operating system  :   Windows 10 Enterprise
2. version of operating system : 20H2
3. version of Lazarus IDE :2..2.2




Jorg3000

  • Jr. Member
  • **
  • Posts: 64
Re: Need help to Create .CSV file using Pascal Lazarus
« Reply #1 on: October 11, 2022, 03:10:18 pm »
Hi!
What do you mean by "data buffer"?

There is a unit CsvDocument ( uses CsvDocument; ) that contains a class TCSVDocument that offers all the methods you need.
https://wiki.freepascal.org/CsvDocument

Best regards, Jörg

Jorg3000

  • Jr. Member
  • **
  • Posts: 64
Re: Need help to Create .CSV file using Pascal Lazarus
« Reply #2 on: October 11, 2022, 03:17:51 pm »
PS:
And if you want to work with files from Excel or LibreOffice directly, I recommend using the unit fpSpreadSheet
https://wiki.freepascal.org/FPSpreadsheet


mas steindorff

  • Hero Member
  • *****
  • Posts: 532
Re: Need help to Create .CSV file using Pascal Lazarus
« Reply #3 on: October 12, 2022, 01:22:08 am »
spreadsheets may have a limited size and come with other baggage.  if all you need is CSV file then use a TStringList. 
Switching between  .commatext and .strings[] gives you the ability to build the records as you wish.
When you save the data, you can either use the built in .SavetoFile() or as I do: save each completed line as .commatext direct to file and you can press pass the 2G Byte file limit.
windows 10 &11, Ubuntu 21+ - fpc 3.0.4, IDE 2.0 general releases

 

TinyPortal © 2005-2018