cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-16034%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EWie%20extrahiere%20ich%20den%20Excel-Dateinamen%20aus%20einer%20vom%20Benutzer%20ausgew%C3%A4hlten%20Datei%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16034%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELeute%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIch%20kann%20anscheinend%20nicht%20herausfinden%2C%20wie%20ich%20den%20urspr%C3%BCnglichen%20Dateinamen%20einer%20Excel-Arbeitsmappe%20extrahieren%20kann%2C%20die%20ein%20Benutzer%20ausw%C3%A4hlt.Nachdem%20ich%20die%20entsprechende%20Datei%20wie%20unten%20gezeigt%20ausgew%C3%A4hlt%20habe%2C%20ist%20der%20tats%C3%A4chliche%20Dateiname%2C%20den%20ich%20erhalte%2C%20der%20Arbeitsblattname%20(Blatt%201)%20und%20nicht%20der%20urspr%C3%BCngliche%20Dateiname%20(test_data.xls).%20Letztendlich%20versuche%20ich%2C%20die%20urspr%C3%BCnglich%20ausgew%C3%A4hlte%20Excel-Datei%20umzubenennen%2C%20und%20ben%C3%B6tige%20dazu%20den%20Dateinamen%20und%20nicht%20den%20Namen%20des%20ge%C3%B6ffneten%20Arbeitsblatts.%20Irgendwelche%20Ideen%2C%20wie%20ich%20das%20erreichen%20kann%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Edt%20%3D%20%C3%96ffnen(%3C%2FP%3E%0A%3CP%3EDatei%20ausw%C3%A4hlen(%20%22Excel-Datei%20ausw%C3%A4hlen%22%2C%20%22%24dir_rawdata%2F%22%2C%20%7B%22Alle%20Dateien%7C*%22%7D%2C%20)%2C%3C%2FP%3E%0A%3CP%3EArbeitsbl%C3%A4tter(%20%E2%80%9E1%E2%80%9C)%2C%3C%2FP%3E%0A%3CP%3EF%C3%BCr%20alle%20Bl%C3%A4tter%20verwenden(%201%20)%2C%3C%2FP%3E%0A%3CP%3EArbeitsbl%C3%A4tter%20verketten(%200%20)%2C%3C%2FP%3E%0A%3CP%3EVerkettungsspalte%20erstellen%20(0)%2C%3C%2FP%3E%0A%3CP%3EArbeitsblatteinstellungen(%3C%2FP%3E%0A%3CP%3E1%2C%3C%2FP%3E%0A%3CP%3EHat%20Spalten%C3%BCberschriften%20(1)%2C%3C%2FP%3E%0A%3CP%3EAnzahl%20der%20Zeilen%20in%20Kopfzeilen%20(3)%2C%3C%2FP%3E%0A%3CP%3E%C3%9Cberschriften%20beginnen%20in%20Zeile%20(1)%2C%3C%2FP%3E%0A%3CP%3EDaten%20beginnen%20in%20Zeile%20(4)%2C%3C%2FP%3E%0A%3CP%3EDaten%20beginnen%20in%20Spalte%20(1)%2C%3C%2FP%3E%0A%3CP%3EDaten%20enden%20in%20Zeile%20(0)%2C%3C%2FP%3E%0A%3CP%3EDaten%20enden%20in%20Spalte%20(0)%2C%3C%2FP%3E%0A%3CP%3EReplizierte%20%C3%BCbergreifende%20Zeilen%20(1)%2C%3C%2FP%3E%0A%3CP%3EVersteckte%20Zeilen%20unterdr%C3%BCcken%20(1)%2C%3C%2FP%3E%0A%3CP%3EVersteckte%20Spalten%20unterdr%C3%BCcken%20(1)%2C%3C%2FP%3E%0A%3CP%3ELeere%20Spalten%20unterdr%C3%BCcken%20(1)%2C%3C%2FP%3E%0A%3CP%3EAls%20Hierarchie%20behandeln(%200%20)%3C%2FP%3E%0A%3CP%3E)%3C%2FP%3E%0A%3CP%3E)%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Efname.old%20%3D%20dt%20%26lt%3B%26lt%3B%20Name%20abrufen%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16038%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20extrahiere%20ich%20den%20Excel-Dateinamen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16038%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CP%3EDas%20ist%20eine%20gute%20Idee%2C%20es%20h%C3%A4ngt%20alles%20davon%20ab%2C%20was%20Ihr%20Skript%20tun%20soll.%20Pers%C3%B6nlich%20hatte%20ich%20das%20Bed%C3%BCrfnis%2C%20mehrere%20Excel-Dateien%20gleichzeitig%20einzulesen%2C%20deshalb%20habe%20ich%20die%20Dateien%20in%20einer%20Liste%20gespeichert%20und%20sie%20mithilfe%20von%20For-Schleifen%20formuliert.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EExceldatei%20%3D%20%7B%7D%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EExcelfile%20%3D%20Datei%20ausw%C3%A4hlen%20()...%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Eviel%20Gl%C3%BCck!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16037%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20extrahiere%20ich%20den%20Excel-Dateinamen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16037%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDanke%20Leute%20f%C3%BCr%20eure%20Vorschl%C3%A4ge%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIch%20habe%20herumgespielt%20und%20festgestellt%2C%20dass%20ich%20eine%20Datentabelle%20aus%20der%20Datei%20definieren%20muss%2C%20die%20in%20der%20Funktion%20%E2%80%9EDatei%20ausw%C3%A4hlen%E2%80%9C%20ausgew%C3%A4hlt%20wurde%3A%20dt.select%20%3D%20Pick%20File(%20%22Excel-Datei%20ausw%C3%A4hlen%22%2C%20......%20Nachdem%20ich%20das%20getan%20hatte%2C%20konnte%20ich%20den%20Dateinamen%20mithilfe%20der%20Word-Funktion%20problemlos%20analysieren.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMS%2C%20vielen%20Dank%20f%C3%BCr%20die%20clevere%20M%C3%B6glichkeit%2C%20den%20Dateinamen%20aus%20der%20Source-Eigenschaft%20zu%20extrahieren.Das%20war%20wirklich%20clever%20und%20es%20war%20sehr%20hilfreich%2C%20etwas%20%C3%BCber%20die%20Verwendung%20von%20-1%20Word%20zu%20lernen.%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16036%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20extrahiere%20ich%20den%20Excel-Dateinamen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16036%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDer%20Dateiname%20ist%20Teil%20des%20%E2%80%9ESource%E2%80%9C-Skripts.%20Ich%20denke%2C%20das%20funktioniert%20(unter%20der%20Annahme%20eines%20POSIX-Pfads)%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22margin%3A%200px%3B%20font-size%3A%2014px%3B%20line-height%3A%20normal%3B%20font-family%3A%20Courier%3B%22%3Efname.alt%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%20%3D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23032ce4%3B%22%3E%20Wort%3C%2FSPAN%3E%3CSTRONG%3E%20(%3C%2FSTRONG%3E%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%20-%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23009193%3B%22%3E%3CSTRONG%3E%201%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%20%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23032ce4%3B%22%3E%20Arg%3C%2FSPAN%3E%3CSTRONG%3E%20(%3C%2FSTRONG%3E%20dt%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%20%26lt%3B%26lt%3B%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%3CSTRONG%3E%20Eigentum%20erwerben%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSTRONG%3E%20(%3C%2FSTRONG%3E%3CSPAN%20style%3D%22color%3A%20%23942193%3B%22%3E%20%22Quelle%22%3C%2FSPAN%3E%3CSTRONG%3E%20)%3C%2FSTRONG%3E%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%20%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23009193%3B%22%3E%3CSTRONG%3E%201%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSTRONG%3E%20)%3C%2FSTRONG%3E%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%20%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23942193%3B%22%3E%20%E2%80%9E%2F%E2%80%9C%3C%2FSPAN%3E%3CSTRONG%3E%20)%3C%2FSTRONG%3E%3CSPAN%20style%3D%22color%3A%20%23011993%3B%22%3E%20%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16035%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20extrahiere%20ich%20den%20Excel-Dateinamen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16035%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHallo%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIch%20habe%20es%20geschafft%2C%20den%20Excel-Dateinamen%20mit%20der%20Funktion%20word()%20zu%20extrahieren%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EZum%20Beispiel%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EExcelfile%20%3D%20Datei%20ausw%C3%A4hlen%20(%22W%C3%A4hlen%20Sie%20Ihre%20CSV-Datei(en)%20aus%22%2C%20%22%22%2C%20%7B%22JMP-Dateien%7Ccsv%22%2C%20%22Alle%20Dateien%7C*%22%7D%2C%201%2C%200%2C%20%22%22%2C%20%22multiple%22%20)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EF%C3%BCr%20(%20%5BLogik%5D%2C%3C%2FP%3E%3CP%3ESampName%3CI%3E%20%3D%20Wort(%20-1%2C%3CSPAN%20style%3D%22font-size%3A%2013.3333px%3B%22%3E%20Excel-Datei%3C%2FSPAN%3E%3CI%3E%20%2C%20%22%2F%22%20)%3B%3C%2FI%3E%3C%2FI%3E%3C%2FP%3E%3CP%3EExcelName%3CI%3E%20%3D%20Word(%201%2C%20SampName%3CI%3E%20%2C%20%22.%22%20)%3B%3C%2FI%3E%3C%2FI%3E%3C%2FP%3E%3CP%3EDateiinhalt%20%3D%20Textdatei%20laden(%3CSPAN%20style%3D%22font-size%3A%2013.3333px%3B%22%3E%20Excel-Datei%3C%2FSPAN%3E%3CI%3E%20)%3B%3C%2FI%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%2F%2FVerwenden%20Sie%20die%20Dateiinhalte%2C%20um%20Ihre%20Zeilen%20zu%20formulieren%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E)%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EDer%20ExcelName%20gibt%20Ihnen%20den%20Namen%20Ihrer%20Excel-Datei%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EProst%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
terapin
Level VI

How do I extract excel filename from a user-selected file?

Folks,

 

I can't seem to figure out how to extract the original file name of an Excel workbook that a user selects.  After selecting the appropriate file as shown below, the actual file name I get is the worksheet name (sheet 1), not the original file name (test_data.xls). I'm ultimately trying to rename the originally selected excel file and need the file name, not the opened worksheet name, to accomplish this. Any ideas how I can accomplish this?

 

dt = Open(

  Pick File( "Select Excel File", "$dir_rawdata/", {"All Files|*"}, ),

  Worksheets( "1" ),

  Use for all sheets( 1 ),

  Concatenate Worksheets( 0 ),

  Create Concatenation Column( 0 ),

  Worksheet Settings(

  1,

  Has Column Headers( 1 ),

  Number of Rows in Headers( 3 ),

  Headers Start on Row( 1 ),

  Data Starts on Row( 4 ),

  Data Starts on Column( 1 ),

  Data Ends on Row( 0 ),

  Data Ends on Column( 0 ),

  Replicated Spanned Rows( 1 ),

  Suppress Hidden Rows( 1 ),

  Suppress Hidden Columns( 1 ),

  Suppress Empty Columns( 1 ),

  Treat as Hierarchy( 0 )

  )

);

 

fname.old = dt << Get Name;

2 ACCEPTED SOLUTIONS

Accepted Solutions
anders_bankefor
Level III

Re: How do I extract excel filename

Hi,

I've managed to extract excelfile name using the word() function:

for example:

Excelfile = pick file ("Select your CSV File(s)", "", {"JMP Files|csv", "All Files|*"}, 1, 0, "", "multiple" );

For ( [logic],

  SampName = Word( -1, Excelfile , "/" );

  ExcelName = Word( 1, SampName, "." );

  file contents = Load Text File( Excelfile );

//use the file cotents to phrase through your rows

)

the ExcelName will give you the name of your excelfile

cheers

View solution in original post

terapin
Level VI

Re: How do I extract excel filename

Thanks folks for your suggestions,

I was playing around and realized I needed to define a data table from the file selected in the Pick File function: dt.select = Pick File( "Select Excel File", ...... Once I did that I was easily able to parse out the file name using the Word function. 

MS, thanks for the clever way of extracting the file name from the Source property.  That was a really clever and learning about the use of -1 Word was very helpful.   

View solution in original post

4 REPLIES 4
anders_bankefor
Level III

Re: How do I extract excel filename

Hi,

I've managed to extract excelfile name using the word() function:

for example:

Excelfile = pick file ("Select your CSV File(s)", "", {"JMP Files|csv", "All Files|*"}, 1, 0, "", "multiple" );

For ( [logic],

  SampName = Word( -1, Excelfile , "/" );

  ExcelName = Word( 1, SampName, "." );

  file contents = Load Text File( Excelfile );

//use the file cotents to phrase through your rows

)

the ExcelName will give you the name of your excelfile

cheers

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How do I extract excel filename

The file name is part of the "Source" script. I think this works (assuming POSIX path):

fname.old = Word(-1, Arg(dt << Get property("Source"), 1), "/");

terapin
Level VI

Re: How do I extract excel filename

Thanks folks for your suggestions,

I was playing around and realized I needed to define a data table from the file selected in the Pick File function: dt.select = Pick File( "Select Excel File", ...... Once I did that I was easily able to parse out the file name using the Word function. 

MS, thanks for the clever way of extracting the file name from the Source property.  That was a really clever and learning about the use of -1 Word was very helpful.   

anders_bankefor
Level III

Re: How do I extract excel filename

Thats a good idea, it all depends on what your script should do. Personally I had the need of reading in several excel files at once, therefore I stored the files into a list and phrased them using for-loops.

Excelfile = {}

Excelfile = pick file ()...

best of luck!

Recommended Articles