how to count file field

Hi,

I have a code that imports the fields from one file(InputFile) and updat the item table.

I am using ‘Common Dialog Management’ code unit for the importing option.

This input file is suppose to have 10 fields with the field filter ’ , ’ (comma).

If the contains less than 10 fields, I need to generate the error saying ‘filed does not match’.

Every thing fine, but please help me on how to calculate the fields in a file ??

Regards,

Abdul.

hi, pls any can help me with this ?

Hi ,

You probably want to share more on what files you are importing and what kind of codes, so people can help you.

g.

Hi,

I am importing from a csv file.

the field separator I given as comma.

I want to read how many comma’s are there in each line, so I could get the field count.

Hi Rahman,

I am facing a problem which you already done.

Actually i import data from csv file to navision table but I want if same primary field data comes again then that update privious data related to primary data.

So can you give me your code for this.

Thanks in advanced

Avinash

Have you considered , using a dataport ?

That would cover your import .

g.

My naive approach without knowing more deatails would be:

Before importing the file I’d open the file, read a line into a text variable and count the commas.

Something like this:

MyFile.read(MyTxtVar);
for i := 1 to strlen(MyTxtVar) do
if MyTxtVar[ i] = ‘,’ then
NoFields := NoFields + 1;

Hi Avinash,

This will happen automatically if the primary key field value repeated.

No need to set any code for it, but define the key for the table field to which you import the file values.

Thank you so much Thomas… That worked !![:D]