1

I want to know what is the best way to create a script in any language for importing a text file in excel. I use to code in java but I'm interrested to learn any other language.

The goal is to import a txt file in excel without opening excel for example using java or vb...

I have a folder where everyday a text file is downloaded and I want to import it in excel and the I could check for graphs.

I tried to import it in java, but it seems it's not possible.

Thank you for your help.

HaskellElephant
  • 9,819
  • 4
  • 38
  • 67
user618111
  • 439
  • 5
  • 15
  • 27
  • 2
    It is possible in Java but may be easier to do in excel as you suggest. Perhaps you should add an [excel] tag instead of [java] – Peter Lawrey Mar 01 '11 at 08:57

2 Answers2

2

I think the best way would be to convert your text file into a .CSV file (Comma Separated Values).

Use whatever language you like, but I would suggest a scripting language like preferably Python.

EDIT: Forgot to mention earlier that CSV files open up in excel by default.

bits
  • 8,110
  • 8
  • 46
  • 55
  • CSV is a "loose" format: it does not define how the dates are to be interpreted, what is the delimiter, etc.. So it's not good for large distribution but fine ofr personnal or departmental use. A little trick, once your csv is ok: just rename it to .xls ! It will then open transparently in Excel. – iDevlop Mar 01 '11 at 10:41
  • By definition, a comma is the delimiter in a CSV file (Comma-Separated Values) – redOctober13 Apr 15 '21 at 15:25
0

Only 10 years late to this party, but I just searched for this questions here in futureland. I know you said "without opening Excel," but unless you make a script that checks for a file and is scheduled with a CRON job or something, you have to do something to convert the file.

I've done it in VBA many times when I wanted Excel output, as it's pretty straightforward to open a file, read it, and put it in Excel however you want, and then you have all the functionality of Excel natively (say if you wanted to make graphs). I've made decent UIs with buttons so the user only has to open the file and click a button to import a text file.

Apart from that, Python and Pandas works pretty well and is pretty flexible; you just have to have a way to execute the script, either manually or on some schedule.

redOctober13
  • 3,662
  • 6
  • 34
  • 61