cheesestain Posted March 21, 2018 Posted March 21, 2018 I'm trying to read a file to an array, strip some data and then write it back to an array so I can put it into an excel file. I'll be writing up to 20K lines to excel so i'm not sure if this is the most efficient way but I'm running into a problem and it looks like no data is written to the array. expandcollapse popup#include <FileConstants.au3> #include <File.au3> Local $VendorFile = "C:\test.txt" Local $OpenVendorFile = FileOpen($VendorFile, $FO_READ) Local $Header = FileReadLine($OpenVendorFile, 1) Local $PO = StringLeft($Header, 10) Local $VendorID = StringStripWS(StringMid($Header, 53, 10), 8) Local $Records = StringMid($Header, 31, 6) Local $ActualRecords = _FileCountLines($VendorFile) - 1 Local $Detail = FileReadLine($OpenVendorFile, 2) Local $MPC = StringStripWS(StringMid($Detail, 31, 20), 8) Local $SAPSKU = "SKUTEST" Local $Description = "MATERIAL DESCRIPTION" FileClose($OpenVendorFile) Local $aVendorFile _FileReadToArray($VendorFile,$aVendorFile) ;_ArrayDisplay($aVendorFile) Local $aExcelArray[$ActualRecords][6] For $k = 2 To UBound($aVendorFile[0]) - 1 $PalletID = StringStripWS(StringMid($aVendorFile[$k],351,30),8) $SerialNumber = StringStripWS(StringMid($aVendorFile[$k],81,20),8) $MasterCarton = StringStripWS(StringMid($aVendorFile[$k],181,20),8) $aExcelArray[$k][0] = $PO $aExcelArray[$k][1] = $SAPSKU $aExcelArray[$k][2] = $Description $aExcelArray[$k][3] = $SerialNumber $aExcelArray[$k][4] = $PalletID $aExcelArray[$k][5] = $MasterCarton Next ;_ArrayDisplay($aExcelArray)
cheesestain Posted March 21, 2018 Author Posted March 21, 2018 I figured it out. I guess what I want to know now is what's the fastest way to write ~20K lines to excel? Writing each line inside the for loop or from the array?
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