Deleting Columns in CSV hi5 / CSV (Lib) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
labrint
Posts: 379
Joined: 14 Jun 2017, 05:06
Location: Malta

Deleting Columns in CSV hi5 / CSV (Lib)

18 Apr 2021, 04:43

Code: Select all

oExcel := ComObjCreate("Excel.Application") ; create Excel Application object
; oExcel.Workbooks.Add ; create a new workbook (oWorkbook := oExcel.Workbooks.Add)
oExcel.Visible := 0 ; make Excel Application Visible  Visible  Visible  Visible  Visible  Visible  Visible  Visible  Visible 
oExcel.DisplayAlerts := 0
oExcel.AlertBeforeOverwriting := 0
oExcel.ScreenUpdating := 0

MsgBox, OPEN STORES EXCEL FILE


Loop,
{
FileSelectFile, SelectedFile
 
if (SelectedFile = "")
    ExitApp
	
else
Break
}

xlCSV = 6
CSVFILENAME := "stores.csv"

oExcel.Workbooks.Open(SelectedFile) 
oExcel.Visible := True ; set to false if you don't need excel to be seen
oExcel.DisplayAlerts := False ; this is Set to False to suppress prompts and alert messages 
oExcel.ActiveWorkbook.SaveAs(A_Desktop . "\" . CSVFILENAME, xlCSV)

oExcel.ActiveWorkbook.Saved := True
oExcel.Quit

While !FileExist(A_Desktop . "\" . CSVFILENAME)
{
    Sleep, 1000
}

Sleep, 1000

CSV_Load(A_Desktop . "\" . CSVFILENAME,data, ",")

Sleep, 100

CSV_DeleteRow(data,1)
CSV_DeleteColumn(data,1)

Sleep, 100

CSV_Save(A_Desktop . "\" CSVFILENAME,data, OverWrite="1")

ExitApp
Couldn't get the function deleting columns, rows to work. Please help.

Is there an even faster method than looping row by row? My file has over 20,000 rows. I switched to CSV because Excel takes ages to load.
User avatar
labrint
Posts: 379
Joined: 14 Jun 2017, 05:06
Location: Malta

Re: Deleting Columns in CSV hi5 / CSV (Lib)  Topic is solved

18 Apr 2021, 05:03

Code: Select all

CSV_Save(CSVFILENAME ,data,"1")

I had an error in the filename. Now its ok.
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: Deleting Columns in CSV hi5 / CSV (Lib)

18 Apr 2021, 14:44

Is there an even faster method than looping row by row? My file has over 20,000 rows. I switched to CSV because Excel takes ages to load.
If the only purpose is to delete the first row and the first column, the following will do that almost instantaneously in Excel:

Code: Select all

oExcel.ActiveSheet.Columns(1).Delete
oExcel.ActiveSheet.Rows(1).Delete
No loop required.
14.3 & 1.3.7

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, OrangeCat and 161 guests