Community forum

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Offline BobbyS  
#1 Posted : Monday, September 23, 2013 10:52:08 PM(UTC)
BobbyS

Rank: No customer

Joined: 9/23/2013(UTC)
Posts: 1
United States
Location: Anniston

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)}
Offline Support  
#2 Posted : Thursday, September 26, 2013 5:08:03 AM(UTC)
Support

Rank: Official support

Joined: 2/23/2008(UTC)
Posts: 11,223

Thanks: 875 times
Was thanked: 446 time(s) in 424 post(s)
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!
Offline Librus Prime  
#3 Posted : Friday, November 29, 2019 9:26:35 PM(UTC)
Librus Prime

Rank: Paid support

Joined: 11/6/2019(UTC)
Posts: 5
Canada
Location: Winnipeg, Manitoba

Thanks: 1 times
Is there an example of the dotnet code suggested above ?
Offline ErikC  
#4 Posted : Monday, December 2, 2019 7:23:00 AM(UTC)
ErikC

Rank: Paid support

Joined: 2/26/2008(UTC)
Posts: 1,520
Netherlands
Location: Amsterdam

Thanks: 114 times
Was thanked: 220 time(s) in 188 post(s)
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.
thanks 1 user thanked ErikC for this useful post.
Support on 12/2/2019(UTC)
Offline al355  
#5 Posted : Monday, December 2, 2019 1:32:48 PM(UTC)
al355

Rank: Paid support

Joined: 12/2/2013(UTC)
Posts: 396
United Kingdom

Thanks: 11 times
Was thanked: 45 time(s) in 41 post(s)
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

thanks 1 user thanked al355 for this useful post.
Support on 12/2/2019(UTC)
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Scroll to Top