Solved

ImportFile Error -4

Posted on 2006-07-11
5
1,538 Views
Last Modified: 2013-12-26
I have the following code where I get retrun error = -4 (which is Invalid Input)


//ML sample

datastore   lds_obj

lds_obj = create datastore
lds_obj.dataobject = "d_rps510_sort"  // NO select stt associated here
lds_obj.SetTransObject(sqlca)

long ll_row
ll_row = lds_obj.ImportFile("C:\rps510_sample.CSV")
If ll_row < 1 Then
   MessageBox("Message","Error : [" + string(ll_row) + "]")
End If
string ls_sortorder
ls_sortorder = "parcel_id A"  // use "A" for ascending or "D" for descending
lds_obj.SetSort(ls_sortorder)
lds_obj.Sort()
lds_obj.SaveAs("C:\rps510_sample_sorted.txt", CSV!, false)
MessageBox("Info","Output File Created")


Whats wrong above ? My datawindow has 17 columnss as that of CSV file and theor datatypes are same though.

Pls help
M
0
Comment
Question by:mahalakshmi_s
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Lordain
ID: 17094097
Posting the following for reference purposes:

dwcontrol.ImportFile ( filename {, startrow {, endrow {, startcolumn       {, endcolumn {, dwstartcolumn } } } } } )

The file should consist of rows of data.

----CHECK THIS----
If the file includes column headings or row labels, set the startrow and startcolumn arguments to skip them. The data types and order of the DataWindow object's columns must match the columns of data in the file.
----CHECK THIS----

If row 1 = headers or row labels then set startcolumn = 2 as this may be causing your issue.
0
 

Author Comment

by:mahalakshmi_s
ID: 17099627
My file doesnt have any col headings or row labels though...
0
 
LVL 4

Accepted Solution

by:
Lordain earned 500 total points
ID: 17100458
Ruling out this cause the next thing I would look at is to make sure your datatypes and size are of the appropriate type and length in your dataobject which I presume is an external data object source.

I just noticed and remembered something about the ImportFile Function.

Inserts data into a DataWindow control or DataStore from a file. The data can be tab-delimited text or dBase format 2 or 3.

Notice:  It does not say its supports a CSV file.  I would save your CSV file into one of the named supporting formats and see if this fixes your problem as I have the feeling it is the CSV format which is throwing your INVALID INPUT Error.
0
 

Author Comment

by:mahalakshmi_s
ID: 17107897
For example, I took just 2 lines of text file n tried Importing.

Maha     PB10
XYZ       ASA9

Well, if there is no comma and 2 words r separated by tab , then Import funtion works perfect. The above example works good.

But my original working TEXT file has commas ,inbetween all columns. Like
Maha,PB10
XYZ,ASA9
How can I convert the comma into TAB delimited, so that I can go ahead with further coding ?
Any idea ??
Many thx
0
 

Author Comment

by:mahalakshmi_s
ID: 17109817
I used Text! argument in SAVEAS method of datawindow and obtained what I wanted. Thx...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now