Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
mazook
Level II

Load CSV from variable

We have a use case where we call Run Program, and the result is a CSV formatted string. Basically, Run Program is running an application which fetches a remote file in CSV format. I know you can write the CSV to the file system, and then read it to a data table from the file system, but is it possible to read the CSV string in memory from a variable, directly to a datatable?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Craige_Hales
Staff (Retired)

Re: Load CSV from variable

This example uses the dos echo command to send a small CSV file back to JMP. It also passes a blob, rather than a filename, to the open function.

csvdata = Run Program(
    Executable( "CMD.EXE" ),
    Options( {"/a", "/q", "/c echo a,b,c&echo 1,2,3&echo 4,5,6"} ),
    ReadFunction( "blob" )
);
show(blobtochar(csvdata));
dt = open(csvdata, "text");

When the open function sees a blob rather than a filename, it depends on the 2nd parameter to find out the type of data. CharToBlob will convert the text you got back from RunProgram to a blob, or you can get RunProgram to give you the blob directly as shown above.

CSV loaded into JMPCSV loaded into JMP

Craige

View solution in original post

1 REPLY 1
Highlighted
Craige_Hales
Staff (Retired)

Re: Load CSV from variable

This example uses the dos echo command to send a small CSV file back to JMP. It also passes a blob, rather than a filename, to the open function.

csvdata = Run Program(
    Executable( "CMD.EXE" ),
    Options( {"/a", "/q", "/c echo a,b,c&echo 1,2,3&echo 4,5,6"} ),
    ReadFunction( "blob" )
);
show(blobtochar(csvdata));
dt = open(csvdata, "text");

When the open function sees a blob rather than a filename, it depends on the 2nd parameter to find out the type of data. CharToBlob will convert the text you got back from RunProgram to a blob, or you can get RunProgram to give you the blob directly as shown above.

CSV loaded into JMPCSV loaded into JMP

Craige

View solution in original post

Article Labels

    There are no labels assigned to this post.