Jump to content

how to use data from my array as a value


Recommended Posts

Ok short and sweet of this is i have a csv file that im importing to a 2d array and i need to take the column from the array and use it as a value for a dir create.

This is how i get my data into the array i got it from a forum post and this part works flawlessly. My problem is i need to figure out how to get column 1's data to be essentially

dircreate("column 1 data")

;

; This example reads any csv file to a AutoIt 2D array.

#include <array.au3>

Local $sFile = "C:\software\sunrise\Local files\test.csv"

;Get number of lines / rows

Local $aREResult = StringRegExp(FileRead($sFile), ".+(?=\v+|$)", 3) ; returns array of every line

Local $iNumLines = UBound($aREResult)

ConsoleWrite("$iNumLines; " & $iNumLines & @CRLF)

;Get number of commas / columns.

Local $aREResult = StringReplace(FileRead($sFile), ",", ",") ; returns number of commas in file

Local $iNumCommas = @extended

ConsoleWrite("$iNumCommas per row; " & Int($iNumCommas / $iNumLines) + 1 & @CRLF)

Global $aMain[$iNumLines][($iNumCommas / $iNumLines) + 1], $iRow = 0 ; Array for csv file

_CSVFileToArray($sFile) ; Fill array from file

_ArrayDisplay($aMain, "csv file Results")

Func _CSVFileToArray($sFile)

Execute(StringTrimRight(StringRegExpReplace(StringRegExpReplace(FileRead($sFile), '"', '""'), "(\V+)(\v+|$)", 'Test1(StringRegExp("\1","([^,]+)(?:,|$)",3)) & '), 3))

EndFunc ;==>_CSVFileToArray

; Fills each row of the required 2D array

Func Test1($aArr)

For $x = 0 To UBound($aArr) - 1

$aMain[$iRow][$x] = $aArr[$x]

Next

$iRow += 1

Return

EndFunc ;==>Test1

$content=$aMain

dircreate($content)

array.au3

Link to comment
Share on other sites

  • Moderators

sinsilenc,

Welcome to the AutoIt forum. :>

What exactly do you mean by: dircreate("column 1 data") :unsure:

Do you mean you want to create a folder for each value in that column like this:

; Data:
Line 11,Line 12,Line 13
Line 21,Line 22,Line 23
Line 31,Line 32,Line 33 

; Folders
Root
 |
 |__Line 11
 |
 |__Line 21
 |
 |__Line 31

If so then you can just use a loop like this:

For $i = 0 To UBound($aMain) - 1
    DirCreate($aMain[$i][0])
Next

Note we use [0] to indicate the first column or row. ;)

If that is not what you meant, could you please explain in more detail what it is you are trying to do. :D

M23

P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

... all i have to say is you rock lol thanks i just couldnt figure out what i was missing cause i tried a few different things.

thats exactly what i was trying to do.

essentially i have a list of pc's where i have to do several things on and one is create a temp dir and copy files over then and execute them. i just couldnt figure out how to push them out from the csv and the rest is cake.

Thanks again

Link to comment
Share on other sites

  • Moderators

sinsilenc,

Glad I guessed correctly! :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@sinsilenc

Hi and Welcome to the forums!!

There's a array tutorial in the wiki (top of your screen) you may want to take a look at :unsure:

actually had that up and i have my array going properly its just i couldnt figure out how to use the data in the array properly.

yea lol i have used auto it for a few months now to deploy different pieces of software and im trying to do it a different way this time for a bunch of thin clients. Thanks for the info though

Edited by sinsilenc
Link to comment
Share on other sites

  • Moderators

sinsilenc,

From your PM:

for $i = 1 to ubound($aMain) - 1

dircopy($aMain[$i][1], $aMain[$i][0])

next

The reason this does not work might be that you have not provided the full path for both parameters.

Any help? :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Sorry i didnt respond sooner. i had figured that one out my boss wanted to use the path c:\windows\temp we were getting permissions errors so i changed it to "c:\program name" and it worked flawlessly.

Ok now the big one im debaiting weather its better to run a seperate command from each pc or just put the code in this exe.

basically what i need to do is run a schedueld task on all these pc's so that i can have an uninstaller run that i copied over then run the installer for the new version afterwards

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...