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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 import multiple text-files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rpaczkowski

USA
Posts

Posted - 04/27/2005 :  3:24:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

eparent

118 Posts

Posted - 04/27/2005 :  5:47:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.


Go to Top of Page

rpaczkowski

USA
Posts

Posted - 04/28/2005 :  07:23:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

eparent

118 Posts

Posted - 04/28/2005 :  09:48:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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;


Go to Top of Page

rpaczkowski

USA
Posts

Posted - 04/28/2005 :  1:48:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
eparent,

Works perfectly, thank you. But why do I have to set iPartialR2=-1? Shouldn't all rows be imported automatically?
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000