Skip to main content
edited body
Source Link

I use this script to recognise a date in a textfile and write the result in anatheranother file.

For[i = 1, i < 20, i++,
  test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\" <> ToString[i] <>".txt", "Text"];
  test2 = {StringCases[test1, DatePattern[{"Year", "Month", "Day"}]],
         StringCases[ToLowerCase[test1], RegularExpression["\\w(?<!\\d)[\\w'-]*"]]};
Write[s, test2]];

The result is a file like this:

![example data file][1]

test3 = ReadList["E:\\data\\MC1 Data\\MC1 Data\\articles\\testfile3.txt"]

Then I would like to make a selection on the date/first column. In this example, mathematica don't recognise it as a datastring. I tried to convert it like

DateString[test3[[All, 1]]]

but that didnt work. Who has a suggestion? [1]: https://i.sstatic.net/vIfRf.gif

I use this script to recognise a date in a textfile and write the result in anather file.

For[i = 1, i < 20, i++,
  test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\" <> ToString[i] <>".txt", "Text"];
  test2 = {StringCases[test1, DatePattern[{"Year", "Month", "Day"}]],
         StringCases[ToLowerCase[test1], RegularExpression["\\w(?<!\\d)[\\w'-]*"]]};
Write[s, test2]];

The result is a file like this:

![example data file][1]

test3 = ReadList["E:\\data\\MC1 Data\\MC1 Data\\articles\\testfile3.txt"]

Then I would like to make a selection on the date/first column. In this example, mathematica don't recognise it as a datastring. I tried to convert it like

DateString[test3[[All, 1]]]

but that didnt work. Who has a suggestion? [1]: https://i.sstatic.net/vIfRf.gif

I use this script to recognise a date in a textfile and write the result in another file.

For[i = 1, i < 20, i++,
  test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\" <> ToString[i] <>".txt", "Text"];
  test2 = {StringCases[test1, DatePattern[{"Year", "Month", "Day"}]],
         StringCases[ToLowerCase[test1], RegularExpression["\\w(?<!\\d)[\\w'-]*"]]};
Write[s, test2]];

The result is a file like this:

![example data file][1]

test3 = ReadList["E:\\data\\MC1 Data\\MC1 Data\\articles\\testfile3.txt"]

Then I would like to make a selection on the date/first column. In this example, mathematica don't recognise it as a datastring. I tried to convert it like

DateString[test3[[All, 1]]]

but that didnt work. Who has a suggestion? [1]: https://i.sstatic.net/vIfRf.gif

Source Link

Text with date, how to convert?

I use this script to recognise a date in a textfile and write the result in anather file.

For[i = 1, i < 20, i++,
  test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\" <> ToString[i] <>".txt", "Text"];
  test2 = {StringCases[test1, DatePattern[{"Year", "Month", "Day"}]],
         StringCases[ToLowerCase[test1], RegularExpression["\\w(?<!\\d)[\\w'-]*"]]};
Write[s, test2]];

The result is a file like this:

![example data file][1]

test3 = ReadList["E:\\data\\MC1 Data\\MC1 Data\\articles\\testfile3.txt"]

Then I would like to make a selection on the date/first column. In this example, mathematica don't recognise it as a datastring. I tried to convert it like

DateString[test3[[All, 1]]]

but that didnt work. Who has a suggestion? [1]: https://i.sstatic.net/vIfRf.gif