Jump to content
UBot Underground

add list to table as column separation problem


Recommended Posts

hello,

 

im having this problem, a i have created 2 lists of information (more on the way), i want to add to table as separate columns. the only problem is, when i set first "add list to table as column" coordinates to row 0 column 0, and second "add list to table as column" coordinates to row 0 column 1, it just ignores the coordinates and put everything in one column, separated with comma. its bothering me a lot because it is really important for me to have this in order. thank you very much for any help. i have standard edition version 4.1 up to date.

Link to post
Share on other sites

clear table(&Table)

clear list(%ListA)

clear list(%ListB)

add list to list(%ListA, $list from text("a

b

c

d", $new line), "Delete", "Global")

add list to list(%ListB, $list from text("A

B

C

D", $new line), "Delete", "Global")

add list to table as column(&Table, 0, 0, %ListA)

add list to table as column(&Table, 0, 1, %ListB)

save to file("{$special folder("Desktop")}\\Table.csv", &Table)

  • Like 1
Link to post
Share on other sites

hello,

 

im having this problem, a i have created 2 lists of information (more on the way), i want to add to table as separate columns. the only problem is, when i set first "add list to table as column" coordinates to row 0 column 0, and second "add list to table as column" coordinates to row 0 column 1, it just ignores the coordinates and put everything in one column, separated with comma. its bothering me a lot because it is really important for me to have this in order. thank you very much for any help. i have standard edition version 4.1 up to date.

 

From what you describe there, I am pretty sure you are making this mistake, that many people do, even myself sometimes, when not paying attention to all the details:

 

You don't really have two lists!

 

You have built or scraped some data into 2 different text variables.

Your data 'looks like' a list, in that of it has a long text with your elements interwoven with commas; however, THAT structure is not a list, UBot Studio - wise...

You should make sure it is a list before you can use the commands you want for tables.

 

Because they are just simple text variables, when you try to add them as different columns, you end up with a table with two columns, indeed... BUT a single row.

As each text variable has texts separated with commas, the comma between the two cells on the first row of the table just gets lost among all the other commas there, making it look like the commands didn't work, when in fact they just did.

 

In order to make sure your initial variables are lists, after scraping the data, you can do the following:

  • Save the data to a .csv file on disk, then load it back again with list from file
  • Another way is to use the list from text to transform programatically your text variable into a list

Whatever suits you...

 

HTH...

Link to post
Share on other sites

thanks for help, but it doesnt solve my problem. maybe i didnt make myself clear..in the debugger, the table is created correctly, as i want. list 1 begins in row 0 and column 0, list 2 in row 0 and column 1. but right after i export it in .csv file, it is all in the same column, separated with comma. im uploading picture of the table so you can understand clearly. thank you for your time and help..

 

ui stat monitor("titles:", $list total(%titles))

ui stat monitor("urls:", $list total(%urls))

ui stat monitor("available sizes:", $list total(%availablesizes))

set(#allproducts, $page scrape("OF ", " PRODUCTS"), "Global")

set(#pages, $eval("Math.ceil({#allproducts}/20);"), "Global")

set(#pagesfortest, 2, "Global")

define Scrape data {

clear table(&trainers)

clear list(%titles)

clear list(%urls)

clear list(%availablesizes)

navigate("http://www.jdsports.co.uk/men/mens-footwear/trainers/", "Wait")

loop(#pagesfortest) {

add list to list(%titles, $page scrape("width=\"170\" alt=\"", "\" title="), "Don\'t Delete", "Global")

add list to list(%urls, $page scrape("productImage\" href=\"", "\">"), "Don\'t Delete", "Global")

click(<innerhtml="next Â»">, "Left Click", "Yes")

}

loop($list total(%urls)) {

navigate($next list item(%urls), "Wait")

add item to list(%availablesizes, $page scrape("name=\"attrValue\" value=\"", "\" id"), "Don\'t Delete", "Global")

wait for browser event("Everything Loaded", "")

wait(1)

}

add list to table as column(&trainers, 0, 0, %titles)

add list to table as column(&trainers, 0, 1, %urls)

}

Scrape data()

save to file("{$special folder("Desktop")}/trainers.csv", &trainers)

 

the image : http://postimage.org/image/gxmr7ffp1/

Link to post
Share on other sites

Without spending a lot of time checking what your script is doing, it seems you are make hard work of it

I think you only need to scrap the page urls in the first loop

Then nav the url list total

You can then scrap all the data form each page using the add table cell command

This would cut all but one list, and only add one counter varialble

Link to post
Share on other sites

thanks for help, but it doesnt solve my problem. maybe i didnt make myself clear..in the debugger, the table is created correctly, as i want. list 1 begins in row 0 and column 0, list 2 in row 0 and column 1. but right after i export it in .csv file, it is all in the same column, separated with comma. im uploading picture of the table so you can understand clearly. thank you for your time and help..

[...]

save to file("{$special folder("Desktop")}/trainers.csv", &trainers)

 

the image : http://postimage.org/image/gxmr7ffp1/

 

It looks as if your Excel doesn't recognize the file as a .csv file.

 

What happens if you load the previously saved file back into UBot, as a table. Does it show right in debugger?

Link to post
Share on other sites

I'm testing your script now - there was an error at runtime, "value cannot be null" (or some such...) that I bypassed with a manual continue, so... you may want to make your code error-proof by employing some error checking IF THEN ELSE mechanisms...

 

It worked well but I'm using OO Calc not Excel to view the file, and it asks me at import what separator to use (so I tick comma)

 

Probably you have Excel setup to open .csv by default w/o import options... or/and you don't have default options set to separate with comma.

 

In any case, the script is ok, it's just your Excel that messes up the viewing.

 

Cheers!

  • Like 1
Link to post
Share on other sites

thank you very much for your help, as you said, the problem was in EXCEL..the selection of comma as separator was needed to clean up and separate the data. well, 5 hours of my work was wasted for this thing <_< , but i can finally move on! thank you again and have a nice day B)

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