Jump to content
UBot Underground

Trouble filling in forms w/ data from CSV


Recommended Posts

I'm having some issues pulling data from a CSV to fill in some html forms. The problem appears to be with how the CSV is being read. For example, data in a typical CSV looks like this:

 

row1_item1, row1_item2, row1_item3, row1_item4

row2_item1, row2_item2, row2_item3, row2_item4

row3_item1, row3_item2, row3_item3, row3_item4

 

I'm trying to fill in 4 form fields, but I'm getting some quirks when Ubot cycles to the 4th field. Here is what I get the first loop through for values for each field (using the sample format above as an example):

 

1. row1_item1

2. row1_item2

3. row1_item3

4. row1_item4 row2_item1

 

.....so, when it gets to the end of a row (or what should be the end), it grabs the 4th value, but also combines it with value1 from the next row. Is this because the 4th item doesn't have a comma delimiter at the end? From what I can tell, it's not standard CSV format to have a comma after the last value in each row. So, I'm a little puzzled by why it's screwing up the last item in each row.

 

Any tips are greatly appreciated.

Thanks.

Link to post
Share on other sites

I'm having some issues pulling data from a CSV to fill in some html forms. The problem appears to be with how the CSV is being read. For example, data in a typical CSV looks like this:

 

row1_item1, row1_item2, row1_item3, row1_item4

row2_item1, row2_item2, row2_item3, row2_item4

row3_item1, row3_item2, row3_item3, row3_item4

 

I'm trying to fill in 4 form fields, but I'm getting some quirks when Ubot cycles to the 4th field. Here is what I get the first loop through for values for each field (using the sample format above as an example):

 

1. row1_item1

2. row1_item2

3. row1_item3

4. row1_item4 row2_item1

 

.....so, when it gets to the end of a row (or what should be the end), it grabs the 4th value, but also combines it with value1 from the next row. Is this because the 4th item doesn't have a comma delimiter at the end? From what I can tell, it's not standard CSV format to have a comma after the last value in each row. So, I'm a little puzzled by why it's screwing up the last item in each row.

 

Any tips are greatly appreciated.

Thanks.

 

 

You need a comma delimiter to discern item 3 from item four. I don't think you need a comma after the last value. The format you have it it should be working fine, unless you are missing the comma between row1_item4 and row2_item1 somehow...?

Link to post
Share on other sites

You need a comma delimiter to discern item 3 from item four. I don't think you need a comma after the last value. The format you have it it should be working fine, unless you are missing the comma between row1_item4 and row2_item1 somehow...?

 

I don't think I'm missing any commas. My input file is being created by Excel (Save as > CSV), so I'm not manually inputting any commas. Excel's default CSV format is to organize things like I originally listed (no comma after the last value in a row). Since this is standard CSV formatting, I'm puzzled as to why my row1 and row2 data is getting mixed together when I put it into the form fields. Perhaps I'm just missing a Ubot command somewhere in my loop that'll solve the problem (I'm very new to Ubot still).

 

Thanks.

Link to post
Share on other sites

Hi vader,

 

I don't think I'm missing any commas. My input file is being created by Excel (Save as > CSV), so I'm not manually inputting any commas. Excel's default CSV format is to organize things like I originally listed (no comma after the last value in a row). Since this is standard CSV formatting, I'm puzzled as to why my row1 and row2 data is getting mixed together when I put it into the form fields.

Remove the spaces from the CSV file.

 

Perhaps I'm just missing a Ubot command somewhere in my loop that'll solve the problem (I'm very new to Ubot still).

Try this: reader.zip

  • Like 1
Link to post
Share on other sites

@IRobot

 

Thanks a lot for that code!!...my bot is now functioning properly. :)

My code was pretty close to yours, but the one thing I was missing (which may have been the cause of my error) was the "Clear List %row" at the beginning of the loop. Can you explain why this is needed? I "assumed" that clear list would clear everything out and I'd just keep looping through Row 1 data over and over....apparently I just don't understand how clear list works.

 

Anyway, thanks again for providing the sample code, it was a HUGE help and big timesaver for me. Cheers!

Link to post
Share on other sites

My code was pretty close to yours, but the one thing I was missing (which may have been the cause of my error) was the "Clear List %row" at the beginning of the loop. Can you explain why this is needed? I "assumed" that clear list would clear everything out and I'd just keep looping through Row 1 data over and over....apparently I just don't understand how clear list works.

No problem mate.

 

The clear list %row is required because the code loops through the row items in the CSV file, and as the code uses variables to access each row item (which is a field value), the list needs to be cleared.

Link to post
Share on other sites

No problem mate.

 

The clear list %row is required because the code loops through the row items in the CSV file, and as the code uses variables to access each row item (which is a field value), the list needs to be cleared.

 

 

Ok, got it. Thanks.

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...