Windows explorer force excel to import -


i want add context menu item windows explorer (windows 7) in order import selected file excel , start import dialog.

i managed add entry following guide: http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/

but when opens file, import dialog skipped , file opened in spreadsheet.

edit: searched exe switches, ones found kind of useless this! edit2: more background asked electricllama

extra background: need import lot of text files excel. not csv fixed width, sure change in immediate future. i'm opening them convert them , add information columns. program x generates table white space spacing ----> excel format table , add information ----> program y opens excel file directly

so made option in windows registry (using regedit) have launch python script handle parsing , calling excel.exe. file type files without extension , python in path windows variable. regedit export escapes quotes (if wondering that):

windows registry editor version 5.00  [hkey_classes_root\*\shell\import excel] @="convert , open excel"  [hkey_classes_root\*\shell\import excel\command] @="python \"path python script\" \"%1\"" 

the python script messy , tailored needs, here is:

import csv, os, sys  #if there no arguments stop if len(sys.argv) > 0:     file = sys.argv[1] else: sys.exit()  fileout = file + ".csv"  data = open(file, "r") open(fileout, 'w').close() #cleans file  dataout = open(fileout, "a")  # using python csv lib, please info on further explanation open(fileout, 'wb') csvfile:     spamwriter = csv.writer(csvfile, dialect='excel')  # needed special handling first line, that's why used < 2     = 1     line in data:         line = line.split()         lineout = [] # clean list after each line parsed         if < 2: lineout.append("")         item in line:              if item != "\"": lineout.append(item.replace("\"", ""))         spamwriter.writerow(lineout)          += 1 data.close() dataout.close()  # launches excel.exe fileout argument os.system("start excel.exe \""+ fileout + "\"") 

i csv file opened in excel wanted. it's faster way having manually select every option in excel import window.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -