sinsilenc Posted April 21, 2011 Share Posted April 21, 2011 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 More sharing options...
Moderators Melba23 Posted April 21, 2011 Moderators Share Posted April 21, 2011 sinsilenc,Welcome to the AutoIt forum. What exactly do you mean by: dircreate("column 1 data") 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 31If so then you can just use a loop like this:For $i = 0 To UBound($aMain) - 1 DirCreate($aMain[$i][0]) NextNote 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. M23P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sinsilenc Posted April 21, 2011 Author Share Posted April 21, 2011 ... 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 More sharing options...
Moderators Melba23 Posted April 21, 2011 Moderators Share Posted April 21, 2011 sinsilenc, Glad I guessed correctly! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 21, 2011 Share Posted April 21, 2011 @sinsilencHi 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 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
sinsilenc Posted April 21, 2011 Author Share Posted April 21, 2011 (edited) @sinsilencHi 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 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 April 21, 2011 by sinsilenc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 21, 2011 Moderators Share Posted April 21, 2011 sinsilenc, From your PM: for $i = 1 to ubound($aMain) - 1 dircopy($aMain[$i][1], $aMain[$i][0]) nextThe reason this does not work might be that you have not provided the full path for both parameters. Any help? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sinsilenc Posted April 21, 2011 Author Share Posted April 21, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now