Longvl85 Posted June 6, 2011 Share Posted June 6, 2011 (edited) I have this program the runs then output results in .ddt file I then have to open the file and extract the data Here is an example: 11 1 8 01-06-2010 1:11 p/m. 8.304358 1 24354 0 1 31 Is there a way for it to output the data into excel columns that I specify below? I currently have to open multiple files and copy and paste all this data into a spread sheet. sometime it coule be 2 files I have to do this for. Very time consuming. Any help would be much appreciated! :-D 11 = Column A 1 = Not used 8 = Not used 01-06-2010 = Not used 1:11 p/m. = Column B 8.304358 = Column C 1 = Not used 24354 = Column D 0 = Not used 1 = Not used 31 = Not used Edited June 6, 2011 by Longvl85 Link to comment Share on other sites More sharing options...
Longvl85 Posted June 6, 2011 Author Share Posted June 6, 2011 I meant to say 20 not 2. 2 I can live with haha Link to comment Share on other sites More sharing options...
MrMitchell Posted June 6, 2011 Share Posted June 6, 2011 (edited) Hi Longvl85 and welcome There are several ways to go about extracting the data... for one way, read up FileReadLine() in the Help File. You'd want to include a loop and maybe a separate variable to keep track of what line you're reading so you know what to keep to transfer to Excel later and what to discard. For another way, use FileRead() then StringRegExp() but this might prove to be more challenging if it's the first time ever dealing with it As for Excel, there's an entire Excel library of functions available. These are also in the Help File under User Defined Functions --> Excel Management. Specifically, you're looking for the functions: _ExcelBookOpen(), _ExcelWriteCell(), for example. Post what you come up with and go from there! Edited June 6, 2011 by MrMitchell Link to comment Share on other sites More sharing options...
smartee Posted June 6, 2011 Share Posted June 6, 2011 hi Longvl85,Firstly, Welcome to the AutoIt forums!! Here's the AutoIt Wiki, a great resource if you wish to become proficient in AutoIt in no time.Also, here's some forum guidelines(very concise) in case you missed it With respect to your question, try searching the help-file for the _FileListToArray(), _FileReadToArray(), _Excel*() functions.Good Luck ,-smartee Link to comment Share on other sites More sharing options...
Longvl85 Posted June 7, 2011 Author Share Posted June 7, 2011 (edited) Thanks guy, Ill do some reading. I already created one Autoit program that saves me a ton of time. Even has a awesome GUI. Now I jsut gotta figure out this new challenge. :-D Edited June 7, 2011 by Longvl85 Link to comment Share on other sites More sharing options...
Longvl85 Posted June 7, 2011 Author Share Posted June 7, 2011 ok so i thought of another way.... $file = FileOpen("c:\output\New Text document.ddt", 0) FileWrite("c:\output\New Text Document2.csv", FileReadLine($file,1)) FileWrite("c:\output\New Text Document2.csv", ",") FileWrite("c:\output\New Text Document2.csv", FileReadLine($file,2)) FileWrite("c:\output\New Text Document2.csv", ",") FileWrite("c:\output\New Text Document2.csv", FileReadLine($file,3)) FileWrite("c:\output\New Text Document2.csv", ",") Now I have to figure out how to read multiple files and put the output of those files on a new row lol. Ahhh the feeling of being noob. Link to comment Share on other sites More sharing options...
Longvl85 Posted June 7, 2011 Author Share Posted June 7, 2011 I think I can append but not sure how to do that. i read that FileWrite can do it. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 7, 2011 Share Posted June 7, 2011 I think I can append but not sure how to do that. i read that FileWrite can do it.It depends on the mode parameter used in the FileOpen statement. Use 1 to open the file in append mode. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
iamtheky Posted June 7, 2011 Share Posted June 7, 2011 here's an excel example #include <excel.au3> Global $finalArray[4] Global $readArray[11] = ["11", "1", "8" ,"01-06-2010", "1:11 p/m." , "8.304358" , "1", "24354" , "0" , "1" , "31"] $finalarray[0] = $readArray[0] $finalarray[1] = $readArray[4] $finalarray[2] = $readArray[5] $finalarray[3] = $readArray[7] Local $oExcel = _ExcelBookNew() _ExcelWriteArray($oExcel, 1, 1, $finalArray) _ExcelBookSaveAs ($oExcel , "C:\testExcel.xls") shellexecute ("C:\testExcel.xls") ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
MrMitchell Posted June 7, 2011 Share Posted June 7, 2011 Using smartee's suggestion...Say you have "C:\temp\test.ddt". This will read it, display the resulting array then open a new excel doc and put the 4 values in Row 1, Columns 1-4 or A-D #include <File.au3> #include <Array.au3> #include <Excel.au3> Dim $aContents[12] $result = _FileReadToArray("C:\temp\test.ddt", $aContents) $a = $aContents[1] $b = $aContents[5] $c = $aContents[6] $d = $aContents[8] $oExcel = _ExcelBookNew() _ExcelWriteCell($oExcel, $a, 1, 1) ;Row 1 Col 1 _ExcelWriteCell($oExcel, $b, 1, 2) ;Row 1 Col 2 _ExcelWriteCell($oExcel, $c, 1, 3) ;Row 1 Col 3 _ExcelWriteCell($oExcel, $d, 1, 4) ;Row 1 Col 4 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