Subscribe Bookmark RSS Feed

I have a folder with 500 files in txt format and want to import them JMP table, each txt file must correspond to a column in JMP. and each column must be added the name of the txt file...???

josealvarez2685

Community Trekker

Joined:

Mar 6, 2015

I have a folder with 500 files in txt format and want to import them JMP table, each txt file must correspond to a column in JMP. and each column must be added the name of the txt file...???

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Could be automated with jsl in a number of ways. How to do it depends on the delimiter used and if the data columns are numeric, character or a mix of both.

This approach should work for numeric columns (although I can think of scenarios where it would fail):


dir = Pick Directory("Pick directory with .txt data files");

files = Files In Directory(dir);

// Remove non-.txt files from list

For(i = N Items(files), i > 0, i--,

    If(Right(files[i], 4) != ".txt",

        Remove From(files, i, 1)

    )

);

delim = "\!n"; // Change this to current delimiter

n = N Items(files);

dt = New Table("500 files");

For(i = 1, i <= n, i++,

    Pat Match(files[i], Pat Break(".") >> colname);

    v = Words(Load Text File(dir || files[i]), delim);

    dt << New Column(colname, values(v));

);



2 REPLIES
Solution

Could be automated with jsl in a number of ways. How to do it depends on the delimiter used and if the data columns are numeric, character or a mix of both.

This approach should work for numeric columns (although I can think of scenarios where it would fail):


dir = Pick Directory("Pick directory with .txt data files");

files = Files In Directory(dir);

// Remove non-.txt files from list

For(i = N Items(files), i > 0, i--,

    If(Right(files[i], 4) != ".txt",

        Remove From(files, i, 1)

    )

);

delim = "\!n"; // Change this to current delimiter

n = N Items(files);

dt = New Table("500 files");

For(i = 1, i <= n, i++,

    Pat Match(files[i], Pat Break(".") >> colname);

    v = Words(Load Text File(dir || files[i]), delim);

    dt << New Column(colname, values(v));

);



josealvarez2685

Community Trekker

Joined:

Mar 6, 2015

Thank you very much for the help

Very useful help, now I have the following problem.

Files in txt have two columns separated by a comma, what I want now is that every file is imported into a table of JMP and the two numbers are separated and placed each one in different columas, and assign the file name txt to the corresponding column.

I am attaching the txt file and as it should be in JMP table.

Thank you very much for the attention 8384_Table JMP.jpg8385_File txt.jpg