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
 Origin Forum
 Import File with several different column seperat
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jan404

Germany
Posts

Posted - 08/31/2005 :  05:27:34 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version :Origin Pro 7.5
Operating System: WinXP

Hi,

I have want to import files with Data structured as follows:

04:30:00 > 0.250,14.675,0.250,36.947,33.578,799.385

I would like to have the columns separated like this (using | as separator):

04|30|00 | 0.250|14.675|0.250|36.947|33.578|799.385

So i would like to designate three different signs as column separator , : >

I tried to use the import wizard but with no sucess, I couldnt find a possibility to assign several symbols as separator.

I tried to find any information in the Forum about this problem, but I couldnt find any, I cant believe nobody else had this problem. Or is the solution very simple and I was just blind?

I could of course use e.g. Excel where different separators are possible, but since I have a large number of files I would like to find a fast and simple way.

Thanks in advance,

Jan

Mike Buess

USA
3037 Posts

Posted - 08/31/2005 :  09:01:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jan,

I believe you're correct that the IW will handle only one separator. Specify comma ',' as separator and when you get to the wizard's Save Filters page check Save Filter and Specify advanced filter options and choose Next. Enter the following script in the LabTalk code box and then Finish.

wks.col=2;
wks.insert(A1 A2 A3 A4);
get col(1) -e npt;
loop (i,1,npt) {
%A=cell(i,1)$;
cell(i,2)$=%[%A,#1,:];
cell(i,3)$=%[%A,#2,:];
%L=%[%A,#3,:];
cell(i,4)$=%[%L,#1,>];
cell(i,5)$=%[%L,#2,>];
};
del col(1);

That will split the first col "04:30:00 > 0.250" into 4 separate cols "04", "30", "00" and "0.250".

Mike Buess
Origin WebRing Member
Go to Top of Page

Leo_Li

China
Posts

Posted - 09/02/2005 :  01:53:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jan,

Another tool you may want to try is the following Origin C codes. It works fine on OriginPro7.5 with the capability to import multiple ASCII files in a batch.

Leo


/**
1. In OriginPro7.5, open "Code Builder"
2. File->New a C file, copy and paste codes (in below) into it, then File->Add to Workspace
3. Tools->Compile
4. In OriginPro7.5 workspace, Open "Script Window"
5. Type "import <number of header lines> <delimiters>", and then press "Enter"
Example:
import 32 ":>,"

Note: the first delimiter appeared in your ASCII file shall appear
in the first place of delimiter string. In your case, the first delimiter
must be ":".

6. In the "Open ASCII" dialog, select multiple files to import...
*/

void import(int nHeaderLines, string strDelimiters)

{
// Open file dialog box
int iNumSelFiles;
StringArray saFiletypes, saFilePaths;
saFiletypes.SetSize(3);
saFiletypes[0]="[ASCII Text (*.TXT)] *.TXT";
saFiletypes[1]="[ASCII Text (*.DAT)] *.DAT";
saFiletypes[2]="[All Files (*.*)] *.*";

iNumSelFiles = GetMultiOpenBox(saFilePaths, saFiletypes, "", "", "Import ASCII");

// Hanle ASCII files one by one
for (int i = 0; i < saFilePaths.GetSize(); i++)
{

Worksheet wks;
ASCIMP ascimp;

if(!AscImpReadFileStruct(saFilePaths[i], &ascimp)==0)
{
printf("Failed to scan and analyse the given file!\n");
return;
}

ascimp.iDelimited = 1;
ascimp.iDelimiter = ASCIMP_DELIM_OTHER;
ascimp.cChar = strDelimiters.GetAt(0);
ascimp.iHeaderLines = nHeaderLines;
ascimp.iTestLines = 4;
ascimp.iMaxTestLines = 50;

// Read to worksheets
wks.Create("Origin");
wks.ImportASCII(saFilePaths[i], ascimp);

// Handle the delimiters left.
for (int j = 1; j < strDelimiters.GetLength(); j++)
{
char cDelimiter = strDelimiters.GetAt(j);
for (int k = 0; k < wks.GetNumCols(); k++)
{
string strCell;
wks.GetCell(0, k, strCell);
int nTokens = strCell.GetNumTokens(cDelimiter);
if (nTokens == 1)
continue;
// Add new columns
for (int l = 0; l < nTokens - 1; l++)
{
string ColName = "";
string ColNameCreated;
wks.InsertCol(k+1, ColName, ColNameCreated);
}
// Row by row
for (int m = 0; m < wks.GetNumRows(); m++)
{
wks.GetCell(m, k, strCell);
// Assume that nTokens will be the same througout the column...
StringArray strTokens;
strTokens.SetSize(nTokens);
strCell.GetTokens(strTokens, cDelimiter);
for (int n = 0, s = 0; n < nTokens; n++, s++)
{
wks.SetCell(m, k + s, strTokens[n]);
}
}
}
}
}
}


Edited by - Leo_Li on 09/02/2005 01:54:46 AM
Go to Top of Page

bigspoon

Russia
Posts

Posted - 05/13/2008 :  01:51:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Origin7.5, WinXP
I want to import txt-files to worksheet data (seperator ; ).

9,9999998E-003; 4,9008414E-010; 5,4990731E-013; 5,7381516E-014; 5,2319814E-014; 5,8350608E-014; 4,3484160E-014; 3,2352763E-014;

Some times ago I did this without problem. I pressed key Import Multiple ASCII. Origin create new worksheet and pass my data to row.

But now I cann't to do this.

--
best regards, Mike
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