Jump to content
UBot Underground

How to Select Data from a Specific Column in a CSV


Recommended Posts

I'm looking to input different data on a form and all the data I need is in one CSV file. I need to be able to select certain data from one column for one field, and then another bit of data from that same line but in a different column for another field. Example:

 

CSV File:

 

lamp,desk,chair

 

Fields Needed to Fill:

 

What do You Sit in?: Chair (line 1, column 3)

What Provides You with Light?: Lamp (Line 1, column 1)

What's Your Lamp On?: Desk (line 1, column 2)

 

Hopefully that makes sense..

Link to post
Share on other sites

You can do this. For loading from a CSV

 

http://www.ubottutorials.com/basic-loading-from-csv-file.html

 

Then what I would do is during the loop I would set a variable during that number in the loop.

 

So if loop = 1 then set variable = "What provides you with light? $Current List Item"

 

ect.

 

If you are doing this on a small scale then this will work. Probably work on a large scale too but would have to be different if you have multiple rows.

 

Should give you an idea how to do it though. Might be an easier way, just this is the first thought that came to mind.

Link to post
Share on other sites

You can do this. For loading from a CSV

 

http://www.ubottutorials.com/basic-loading-from-csv-file.html

 

Then what I would do is during the loop I would set a variable during that number in the loop.

 

So if loop = 1 then set variable = "What provides you with light? $Current List Item"

 

ect.

 

If you are doing this on a small scale then this will work. Probably work on a large scale too but would have to be different if you have multiple rows.

 

Should give you an idea how to do it though. Might be an easier way, just this is the first thought that came to mind.

 

 

That's great Aaron, thanks man! I sent you a PM (well, I tried to) and it didn't work so I sent you an email.

Link to post
Share on other sites

That's great Aaron, thanks man! I sent you a PM (well, I tried to) and it didn't work so I sent you an email.

 

Ya looks like PM's arent working. Will check my email in a bit. On my laptop watching my kids now. :)

Link to post
Share on other sites

Alright, I'll tell you what I ended up doing and see if you think it was an alright way to do it. I had to do it this way because the CSV file I have has 30,000 rows in it and 3 columns and I needed to make sure it always selected data from the same row.

 

I divided the CSV file into 3 seperate .txt files. I then created a "set parameter" that randomly selects a number between 1 and 30,000.

 

Then, I set it to fill in a field with "list item 1" and it asks for a specific list location. I feed it the number that was randomly generated. Then, for field two, I fill that with "list item 2" and again it asks for a specific location, and I just feed it with the same number that was randomly generated.

 

I tested it out, and it always gets data from the same row. Next loop around, it generates a new random number to use for all the fields...so on and so forth.

Link to post
Share on other sites

Meaning I am in the living room playing with my kids and watching them. But I had my laptop so would browse around. :)

 

Oh, haha, that makes sense. I thought you meant via a "nanny cam" or something. Did you happen to see my post directly above "I just realized you said "watching my kids on my laptop now"....??" that?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...