Reply To: Reading a csv file in JVS Table

#9321
Gareth Evenson
Participant

Hi Saurabh

You can use these functions with an empty table and they will create the columns.

So if you run this example code:

package com.custom;

import com.olf.openjvs.*;
import com.olf.openjvs.enums.*;

public class TestFileImport implements IScript
{
public void execute(IContainerContext context) throws OException
{
Table importTable = Table.tableNew();
String fileName = “C:\\Users\\gevenson\\Documents\\TestFile.csv”;
importTable.inputFromCSVFile(fileName);
importTable.viewTable();
importTable.destroy();
}
}

With a file like this:

col1,col2,col3
value1, value2, value3
value4, value5, value6

Then you get a 3 column table produced with all columns of type string. The header row is not distinguished however so you need to take then first row and rename the columns accordingly.

Download PDF version

This field is for validation purposes and should be left unchanged.