Sign in to follow this  
Followers 0
ReFran

Reading data to dynamic arrays ?

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I've a spreadsheet (not excel) with 8 rows and 30 cols, where the rows can be dynamic.

This data I write from the spreadsheet file into a csv. Thats OK!

In AutoIT I want to use the data from the csv-file in different listviews and other controlls.

I thought the best would be read the data with stringsplit into different arrays.

something like $aRow1, $aRow2, $aRow3, ......

So if I want to use the data I know it is $aRow11[16].

I though I can do it in a for loop, but $aRow &i do'nt work.

DIM $aRow1, $aRow2, $aRow3 .... seems not to be good because I don't know how much rows.

Array into array seems also not to be a good solution, because I need different data by rows and cols.

I think to dim a multi array maybe a little bit to much for such few data, but I'm not sure.

Perhaps someone can give a hint, how to solve it.

Thanks in advance, Reinhard

Edited by ReFran

Share this post


Link to post
Share on other sites



This will read a csv into a listview.

#include <GUIConstants.au3>
#include <File.au3>

Dim $csvArray

;Read CSV to array
_FileReadToArray("Book1.csv", $csvArray)

;Replace all commas with pipe symbols
For $X = 1 to $csvArray[0]
    $csvArray[$X] = StringReplace($csvArray[$X],",", "|")
Next

GUICreate("CSV Listview",220,250, 100,200)

;Use first row as header
$listview = GUICtrlCreateListView ($csvArray[1],10,10,200,150);,$LVS_SORTDESCENDING)

;Create all listview items
For $X = 2 to $csvArray[0]
    GUICtrlCreateListViewItem($csvArray[$X],$listview)
Next

GUISetState()

Do
  $msg = GUIGetMsg ()
Until $msg = $GUI_EVENT_CLOSE

Book1.csv:

Color,Style,Price
Blue,Original,$5.00 
Green,Unoriginal,$7.00 
Red,Original,$6.50

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for the qucik answer and code.

I thought to store the data first in an array as central data storage, because only some data are needed for the listview. Some goes into different input boxes for editing, some only labels, some into a dropdownbox, .....

That are product master file data (for only some few products). Some data in the first listview (ProdId, ProdName, Total Sales) and at the botton some Inputboxes for editing, e.g. Productgroup, security data, storage code ... prefilled with data from the first and renewed with a click on a listview item.

However, maybe I store it all in the listview and then hide some cols, so I have a central data storage.

Best regards, Reinhard

Edited by ReFran

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0