0

I've been learning Python for a week now and am currently at Exercise 26 (learnpythonthehardway). So I know nothing. I tried searching but couldn't find what I need.

What I need: I want to write a script that breaks my Journal.txt file into several text files to be able to import them into Evernote. Evernote pulls the title for a note from the first line of the .txt

This is a random example of the date format I used in my Journal.txt

1/13/2013, 09/02/2012, so I'm afraid the date is not consistent. I know about:

if 'blabla' in open('example.txt').read():

but don't know how to use it with a date. Please help me to elicit date corresponding Journal entries from a large file into a new one. This is literally all I got so far:

Journal = open("D:/Australien/Journal.txt", 'r').read()
mmlkrx
  • 1

1 Answers1

0

Consider doing it like recommended here - replacing YOUR_TEXT_HERE with a search pattern for a date, e. g. [0-9]+\/[0-9]+\/[0-9]+.

awk "/[0-9]+\/[0-9]+\/[0-9]+/{n++}{print > n \".txt\" }" a.txt

If you don't have awk installed on your PC, you can fetch it here.

Community
  • 1
  • 1
Armali
  • 18,255
  • 14
  • 57
  • 171