|
From: theozh <th...@gm...> - 2018-11-10 06:06:06
|
Hi, I would like to read a file (as is) into a datablock.
I basically found two ways to do this. See code below.
First question:
My concern is that in Method1 the file has to be read/accessed (row)-times from disk whereas Method2 only once. If I have a file with several thousands or million rows on a very slow network connection this probably would take rather long, correct? I currently cannot test.
Can anybody comment on this?
Second question:
When reading the file via Method2 the datablock contains a space at every beginning of the line.
Can anybody explain why and how to avoid? Bug or feature?
Assuming the file "Test.dat" looks for example like the following:
# Test.dat
# Some test data
# more comments
1 2 3
4 5 6
7 8 9
Here is the code:
### Read file to datablock
reset session
FILE = "Test.dat"
set datafile separator "\n"
set datafile commentschar ""
# Method1
stats FILE u 0 nooutput
set print $Data1
set table $Dummy
do for [row=0:STATS_records-1] {
plot FILE u (a=stringcolumn(1),a) every ::row::row with table
print a
}
unset table
set print
print $Data1
# Method2
set table $Data2
plot FILE u (stringcolumn(1)) with table
unset table
print $Data2
### end of code
|