Don't create one massive string, but rather create data tables one by one and concatenate those as you go. Also when posting JSL scripts please use "Insert JSL Script" as it makes it much easier to read.
Names Default To Here(1);
dir = "$DOWNLOADS/New Folder (7)";
filelist = Files In Directory(dir);
mylist = {};
dt_collector = Empty();
For(i = 1, i <= N Items(filelist), i++,
file = dir || "/" || filelist[i];
str = Load Text File(file);
lines = Words(str, "\!N");
data = Transform Each({line}, lines,
line = Collapse Whitespace(Substitute(line, {"(", ")"}, ""))
);
modifiedstr = Concat Items(data, "\!N");
dt = Open(
Char To Blob(modifiedstr),
Import Settings(
End Of Line(CRLF, CR, LF),
End Of Field(Spaces, Space, CSV(0)),
Strip Quotes(1),
Use Apostrophe as Quotation Mark(0),
Use Regional Settings(0),
Treat empty columns as numeric(0),
Compress Numeric Columns(0),
Compress Character Columns(0),
Compress Allow List Check(0),
Labels(1),
Column Names Start(1),
First Named Column(1),
Data Starts(2),
Lines To Read("All"),
Year Rule("20xx")
),
invisible
);
dt << Set Name(filelist[i]);
dt << New Column("Source", Character, Nominal, << Set Each Value((dt << get name)));
If(!Is Empty(dt_collector),
dt_collector << Concatenate(
dt,
Append to first table
);
Close(dt, no save);
,
dt_collector = dt;
);
);
-Jarmo