The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 import multiple text-files

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
rpaczkowski Posted - 04/27/2005 : 3:24:37 PM
Origin Version (Select Help-->About Origin): 7.5 SR5
Operating System: Win 2000 Pro

I want to import multiple text-files. The first 5 rows of each file should be discarded, rows 6 and 7 should be the column labels. Then come the data in 4 columns. At the bottom of the files, I have some text that I want to import as well. Using the import wizard, I determined that I need ten columns to get the whole text. Here is my code:

//Import multiple .txt-files
int inumfiles;
StringArray saFilePaths;
inumfiles=GetMultiOpenBox(saFilePaths, "*.txt");
Worksheet wks;

//Import data into worksheets and rename them after file names
for (int ii=0; ii<saFilePaths.GetSize(); ii++)
{
wks.Create("Origin.OTW");
ASCIMP ascimp;
ascimp.iNumColumns=10;
ascimp.iHeaderLines=5;
ascimp.iAutoSubHeaderLines=0;
ascimp.iSubHeaderLines=2;
ascimp.iRenameCols=1;
ascimp.iDelimited=1;
ascimp.iDelimiter=ASCIMP_DELIM_SPACE;
ascimp.iRenameWks = 1;
wks.SetASCIMP(ascimp);
wks.ImportASCII(saFilePaths[ii],ascimp);

But what I get is row 6 as column labels, row 7 as data, everything else is not imported. How do I have to set the ascimp structure to import everything the way I want without setting up a template?

Ralph
4   L A T E S T    R E P L I E S    (Newest First)
rpaczkowski Posted - 04/28/2005 : 1:48:57 PM
eparent,

Works perfectly, thank you. But why do I have to set iPartialR2=-1? Shouldn't all rows be imported automatically?
eparent Posted - 04/28/2005 : 09:48:12 AM
Ralph,

This file will not import perfectly since the format is not consistent. I say this because if space is the delimiter then there are 5 column names, 3 column units, and 4 data columns. Despite this it is possible to get the 10 columns you are requesting. Please note that due to the inconsistency I described above column names and labels do not come in correctly but all the data and the remaining lines are imported.

Set these additional ASCIMP settings and you should be able to import your whole file.

ascimp.iPartial = 1; // enable partial import
ascimp.iPartialR2 = -1; // import all rows
ascimp.iPartialC2 = ascimp.iNumColumns;
ascimp.iLabels = 1;
ascimp.iMaxLabels = 1;


rpaczkowski Posted - 04/28/2005 : 07:23:59 AM
eparent,

Here are a few lines (the first 2 rows are empty):

(empty row)
(empty row)
Curve Name:
!SAMPLE PIPE CODE 3401-81 1952HR 95C "G
Curve Values:
Index Time Sample Temp Value
[s] [°C] [Wg^-1]
0 0.0000 -50.0016 -0.0283
2 2.0000 -49.9683 -0.0279
4 4.0000 -49.9349 -0.0275
6 6.0000 -49.9016 -0.0271
8 8.0000 -49.8682 -0.0269
10 10.0000 -49.8349 -0.0267
12 12.0000 -49.8015 -0.0266
16196 16196.0000 219.9868 0.2479
16198 16198.0000 220.0202 0.2479
16200 16200.0000 220.0535 0.2479
Results:
Sample:
SAMPLE PIPE CODE 3401-81 1952HR 95C "G", 4.1400 mg
Evaluation:


Hope this helps

Ralph
eparent Posted - 04/27/2005 : 5:47:22 PM
Ralph,

Can you please post a copy of your data file? You do not need to post all the data elements. The header lines, a few lines of data, and the text at the bottom of the file should be enough for me to play with. This will allow me to help you get the right ASCIMP settings.



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000