import re
PATENTS = 'C:\\temp\left.txt'
def split_file(filename):
# Open file to read
with open(filename, "r") as r:
# Counter
n=0
# Start reading file line by line
for i, line in enumerate(r):
# If line match with teplate -- <?xml --increase counter n
if re.match(r'timestamp, x, y, z', line):
n+=1
# This "if" can be deleted, without it will start naming from 1
# or you can keep it. It depends where is "re" will find at
# first time the template. In my case it was first line
if i == 0:
n = 0
# Write lines to file
with open("{}-{}.csv".format(PATENTS, n), "a") as f:
f.write(line)
split_file(PATENTS)
Found it at Stackoverflow.
Need to modify the JS-code slightly to create just one file per event type, but that's not a biggie. After that I might have most other things in place for a write-up.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok, to split files with Python, this can be used
Found it at Stackoverflow.
Need to modify the JS-code slightly to create just one file per event type, but that's not a biggie. After that I might have most other things in place for a write-up.