Jump to content


Photo

How do you add data from a csv column to a list?


  • Please log in to reply
5 replies to this topic

#1 mdc101

mdc101

    Advanced Member

  • UBot Users
  • PipPipPip
  • 91 posts
  • OS:Windows 7
  • Total Memory:4Gb
  • Framework:v4.0
  • License:Dev

Posted 19 February 2012 - 10:02 AM

Hi Folks

I have been looking all over the forum to find the simple way of buildinga list from a csv file.
What needs to be done is a column must be specified and all data in the column added to a list.

How is this done as it is baffling me?

#2 JohnB

JohnB

    Advanced Member

  • UBot Users
  • PipPipPip
  • 3350 posts
  • LocationNJ
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 19 February 2012 - 12:19 PM

Try this:

set(#position, 0, "Global")
loop($table total rows(&YOUR TABLE)) {
add item to list(%LISTNAME, $table cell(&YOUR TABLE, #position, 0), "Delete", "Global")
increment(#position)
}

John

#3 mdc101

mdc101

    Advanced Member

  • UBot Users
  • PipPipPip
  • 91 posts
  • OS:Windows 7
  • Total Memory:4Gb
  • Framework:v4.0
  • License:Dev

Posted 19 February 2012 - 12:53 PM

Hi John

Thanks for the reply

In the code block is the sample data that is in the csv.
All I need from this file at this particular time is the keywords in the "Keyword" column. Column A in spreadsheet.

How do we get this column into a table as the data is downloaded and then as I move through a procedure I need to use / call the keywords from the csv file to add to a list or variable?

If you save the sample as sample.csv and then show us I am sure this will help a lot of us who need to use flat file data to save memory especially when the lists can be a few thousand rows.



Keyword,Search Volume,CPC,Competition,Number of Results,Trends
home security systems,33100,24.80,1.00,94700000,0.67,0.67,0.55,0.55,0.55,0.55,0.55,0.67,0.82,0.82,0.99,0.99
home security,33100,25.61,1.00,2100000000,0.55,0.55,0.55,0.67,0.67,0.67,0.99,0.55,0.67,0.45,0.45,0.37
brinks home security,22200,18.57,0.96,1480000,0.82,0.82,0.99,0.99,0.99,0.99,0.99,0.99,0.99,0.99,0.99,0.99
home security system,6600,26.40,1.00,793000000,0.99,0.99,0.67,0.67,0.67,0.99,0.81,0.67,0.67,0.81,0.99,0.81
home security systems reviews,5400,23.00,0.93,94700000,0.44,0.44,0.99,0.99,0.99,0.67,0.55,0.44,0.36,0.28,0.28,0.16
adt home security,5400,12.71,0.96,18600000,0.82,0.82,0.82,0.99,0.82,0.82,0.67,0.67,0.82,0.82,0.99,0.67
home security cameras,5400,8.08,1.00,49300000,0.99,0.99,0.54,0.54,0.54,0.54,0.81,0.81,0.81,0.67,0.54,0.54
home security companies,5400,28.82,0.95,65000000,0.99,0.99,0.82,0.99,0.99,0.82,0.82,0.82,0.67,0.67,0.82,0.67
xp home security 2011,4400,0.82,0.37,51700000,0.00,0.00,0.01,0.01,0.02,0.20,0.99,0.82,0.55,0.04,0.00,0.00
home security camera,4400,5.86,1.00,39200000,0.81,0.81,0.81,0.67,0.99,0.99,0.54,0.54,0.67,0.54,0.81,0.99
home security store,4400,1.64,0.81,61700000,0.99,0.99,0.82,0.82,0.82,0.82,0.99,0.99,0.99,0.82,0.82,0.99
security systems for home,4400,23.83,1.00,125000000,0.55,0.55,0.82,0.99,0.99,0.82,0.82,0.82,0.99,0.82,0.99,0.99
wireless home security systems,3600,15.89,1.00,27200000,0.99,0.99,0.82,0.82,0.82,0.82,0.66,0.55,0.66,0.66,0.82,0.66
brinks home security systems,3600,22.17,1.00,687000,0.55,0.55,0.82,0.99,0.82,0.82,0.82,0.99,0.99,0.82,0.66,0.66
xp home security,3600,0.69,0.34,39900000,0.01,0.01,0.02,0.13,0.20,0.45,0.99,0.67,0.36,0.05,0.00,0.00
home security camera systems,3600,9.25,1.00,17900000,0.67,0.67,0.67,0.99,0.81,0.67,0.54,0.54,0.54,0.54,0.54,0.54


#4 JohnB

JohnB

    Advanced Member

  • UBot Users
  • PipPipPip
  • 3350 posts
  • LocationNJ
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 19 February 2012 - 01:00 PM

Well not knowing your process, the only thing I can say is if you already have the csv file created then you just use the $create table from file command and then loop through column 0 as I posted above.


John

#5 mdc101

mdc101

    Advanced Member

  • UBot Users
  • PipPipPip
  • 91 posts
  • OS:Windows 7
  • Total Memory:4Gb
  • Framework:v4.0
  • License:Dev

Posted 19 February 2012 - 03:31 PM

Hi John

Thanks for the response. Lily pinged me a section of code that did the trick and I want to share with everyone as I have tried doing this for days.

See code to call data from csv or xls files into a list

create table from file("C:\\path_to_file.csv", &mytable)
set(#counter, 0, "Global")
loop($table total rows(&mytable)) {
    add item to list(%mylist, $table cell(&mytable, #counter, 0), "Delete", "Global")
    increment(#counter)
}
remove from list(%mylist, 0)


#6 mdc101

mdc101

    Advanced Member

  • UBot Users
  • PipPipPip
  • 91 posts
  • OS:Windows 7
  • Total Memory:4Gb
  • Framework:v4.0
  • License:Dev

Posted 19 February 2012 - 03:33 PM

John you were spot on as usual!
What threw me was the create table command which I was not aware off.

Thanks for the replies




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users