Skip to main content
edited body
Source Link
John Taylor
  • 6.1k
  • 2
  • 18
  • 36

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

Edit.

It seems that I have solved this problem.

This is my current attempt:

 FilenameParameters[i_] := StringCases[Filenames[[i]]StringCases[filenames[[i]], mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta=" ~~ angle : NumberString ~~ ".txt" :> {mixing, mass, angle}] 

E.g.,

FilenameParameters[1] 

returns

{{"Electron", "100100.0"0, "00.00715642"009238898}}

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

Edit.

It seems that I have solved this problem.

This is my current attempt:

 FilenameParameters[i_] := StringCases[Filenames[[i]], mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta=" ~~ angle : NumberString ~~ ".txt" :> {mixing, mass, angle}] 

E.g.,

FilenameParameters[1] 

returns

{{"Electron", "100.0", "0.00715642"}}

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

Edit.

It seems that I have solved this problem.

This is my current attempt:

 FilenameParameters[i_] := StringCases[filenames[[i]], mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta=" ~~ angle : NumberString ~~ ".txt" :> {mixing, mass, angle}] 

E.g.,

FilenameParameters[1] 

returns

{{"Electron", 100.0, 0.009238898}}

added 578 characters in body
Source Link
John Taylor
  • 6.1k
  • 2
  • 18
  • 36

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

Edit.

It seems that I have solved this problem.

This is my current attempt:

 FilenameParameters[i_] :=    StringCases[Filenames[[i]],   mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta" ~~ "_theta=" ~~ angle : NumberString ~~ ".txt" :> {mixing, FromDigits[mass]mass,   FromDigits[angle]angle}] 

But it does not work:E.g.,

FilenameParameters[1] 

returns empty

{{"Electron", "100.0", "0.00715642"}}

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

This is my current attempt:

FilenameParameters[i_] :=    StringCases[Filenames[[i]],   mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta" ~~ angle : NumberString ~~ ".txt" :> {mixing, FromDigits[mass],   FromDigits[angle]}] 

But it does not work:

FilenameParameters[1] 

returns empty.

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

Edit.

It seems that I have solved this problem.

This is my current attempt:

 FilenameParameters[i_] := StringCases[Filenames[[i]], mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta=" ~~ angle : NumberString ~~ ".txt" :> {mixing, mass, angle}] 

E.g.,

FilenameParameters[1] 

returns

{{"Electron", "100.0", "0.00715642"}}

added 578 characters in body
Source Link
John Taylor
  • 6.1k
  • 2
  • 18
  • 36

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

This is my current attempt:

FilenameParameters[i_] := StringCases[Filenames[[i]], mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta" ~~ angle : NumberString ~~ ".txt" :> {mixing, FromDigits[mass], FromDigits[angle]}] 

But it does not work:

FilenameParameters[1] 

returns empty.

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

Consider a few files with filename structure

data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt 

where XX/YY may have an arbitrary number of digits.

I use

files= FileNames["*.txt", FileNameJoin[{NotebookDirectory[], "data/Neutrino distribution functions/"}]]; Filenames = Table[Last@FileNameSplit@files[[i]], {i, 1, Length[files], 1}]; 

say,

 filenames = {"Electron_distribution_mass=100.0_theta=0.009238898.txt", "Electron_distribution_mass=100.0_theta=0.01600224.txt", "Electron_distribution_mass=10.0_theta=0.5074418.txt"} 

Could you please tell me how to obtain the output in the form

{NAME,XX.0, 0.YY} 

This is my current attempt:

FilenameParameters[i_] := StringCases[Filenames[[i]], mixing__ ~~ "_distribution_mass=" ~~ mass : NumberString ~~ "_theta" ~~ angle : NumberString ~~ ".txt" :> {mixing, FromDigits[mass], FromDigits[angle]}] 

But it does not work:

FilenameParameters[1] 

returns empty.

added 209 characters in body
Source Link
John Taylor
  • 6.1k
  • 2
  • 18
  • 36
Loading
Source Link
John Taylor
  • 6.1k
  • 2
  • 18
  • 36
Loading