Skip Header reading CSV file - VisualCron - Forum

Community forum

BobbyS
2013-09-23T20:52:08Z
I am downloading a csv file and then looping through the file to insert data into SQL. This is working fine except the CSV file has a header and I need to skip row 1. How do I do this? I'm using the Loop For each row x in {TASK(PrevTask,StdOut)}
Support
2013-09-26T03:08:03Z
We will soon add some more Variables functions to extract specific lines.

Meanwhile I think it is safest to use the .NET code Task to extract the data. You could also combine a couple of Variable functions to remove the first line from the full data but I would recommend using the .NET code Task instead.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Librus Prime
2019-11-29T20:26:35Z
Is there an example of the dotnet code suggested above ?
ErikC
2019-12-02T06:23:00Z
Hi Librus,

If .net is a big questionmark for you, what you also can do is adding a job variable which is a counter (integer).
When you start the job, use a task to set this to: 0.
Then in the 1st task of the loop add a task to add 1 to this counter.
The sql statement task should have a condition to it. It checks if the value of job variable counter is equal to 1. If so, skip this task, else continue.

The next time in the loop, the counter gets a +1 again and equals to 2.
The condition on the sql task checks again the variable to value 1, which it isn't and the sql statement task is alowed.

This should do the trick, but .net ls a nice language to learn. You can do a lot with it, you can even make VisualCron ;-)

Regards,
Erik
Uses Visualcron since 2006.
al355
2019-12-02T12:32:48Z
One other way to do this is to remove the headers using a simple Powershell task

(Get-Content $file | Select-Object -Skip 1) | Set-Content $file

Scroll to Top