CSV File

How i Can Make a CSV File From my Db

Programmatically or using a utility to just get a CSV out?


the Data Base is Visual FoxPro
I need to get the Data and Save in CSV Files but if any Utility that can do this is perfect.

You’ll have to use OleDb to open that database and then loop around the record set, using the field names for columns and the values as the data. Each row would effectively be a row in your CSV, but you could save some time and performance by using an array for each row – then use the Xojo Join to create the row with a delimiter.

how i save the File

I’ve never done this so on Xojo I have no idea

I have done this on Vb6.0


As Gary said, you’ll loop through each record and create a string that holds the contents of the record separated by your comma for CSV: “Alexis”,“Lugo”,“next”,“next” then write that line to a textoutput stream. From the docs:

Dim file As FolderItem Dim fileStream As TextOutputStream file = GetSaveFolderItem("", "MyInfo.txt") If file <> Nil Then fileStream = TextOutputStream.Create(file) fileStream.WriteLine(MyDatabaseRecord.Text) fileStream.Close End If

ok Thanks

Save the Data Like


filestream.writeline field1+","+field2+","+field3

Be aware this is over simplified… if you have string values that CONTAIN “,” you need to wrap them in double quotes

Well if this is a one off, simply use OleDb to load the data into Excel and save it as a CSV file.