Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
dkraeuter_sunne
Level III

Importing Text Files

I am importing a text files that uses more than just commas to separate values. Here is the basic function I am using.

 

open("$desktop/jsonfiles/test.json","text")

 

How do I modify the function to identify other characters such as "[" to be used to identify a new column of data?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Craige_Hales
Staff (Retired)

Re: Importing Text Files

The source script in a successful import using the text import wizard will get you what you need. You can add one character to the list of delimiters like this:

Open(
    "C:\...23a569_1.json",
    Import Settings(
        End Of Line( CRLF, CR, LF ),
        End Of Field( Comma, Other( "[" ), CSV( 0 ) ),
        Strip Quotes( 1 ),
        Use Apostrophe as Quotation Mark( 0 ),
        Use Regional Settings( 0 ),
        Scan Whole File( 1 ),
        Treat empty columns as numeric( 0 ),
        CompressNumericColumns( 0 ),
        CompressCharacterColumns( 0 ),
        CompressAllowListCheck( 0 ),
        Labels( 0 ),
        Column Names Start( 1 ),
        Data Starts( 1 ),
        Lines To Read( "All" ),
        Year Rule( "20xx" )
    )
)

 This will not work for json files in general, but it might work for yours because the rows in the data are on a single line of json text.

Craige

View solution in original post

1 REPLY 1
Highlighted
Craige_Hales
Staff (Retired)

Re: Importing Text Files

The source script in a successful import using the text import wizard will get you what you need. You can add one character to the list of delimiters like this:

Open(
    "C:\...23a569_1.json",
    Import Settings(
        End Of Line( CRLF, CR, LF ),
        End Of Field( Comma, Other( "[" ), CSV( 0 ) ),
        Strip Quotes( 1 ),
        Use Apostrophe as Quotation Mark( 0 ),
        Use Regional Settings( 0 ),
        Scan Whole File( 1 ),
        Treat empty columns as numeric( 0 ),
        CompressNumericColumns( 0 ),
        CompressCharacterColumns( 0 ),
        CompressAllowListCheck( 0 ),
        Labels( 0 ),
        Column Names Start( 1 ),
        Data Starts( 1 ),
        Lines To Read( "All" ),
        Year Rule( "20xx" )
    )
)

 This will not work for json files in general, but it might work for yours because the rows in the data are on a single line of json text.

Craige

View solution in original post

Article Labels

    There are no labels assigned to this post.