Switched to better delimiters (tab and ASCII31)

This commit is contained in:
Krateng 2018-11-26 12:55:17 +01:00
parent 4c2266b9d6
commit 2f8720898b
3 changed files with 9 additions and 8 deletions

View File

@ -128,17 +128,17 @@ def build_db():
for f in os.listdir("logs/"):
if not (".csv" in f):
if not (".tsv" in f):
continue
logfile = open("logs/" + f)
for l in logfile:
l = l.replace("\n","")
data = l.split(",")
data = l.split("\t")
## saving album in the scrobbles is supported, but for now we don't use it. It shouldn't be a defining part of the track (same song from Album or EP), but derived information
artists = data[1].split("/")
artists = data[1].split("")
#album = data[3]
title = data[2]
time = int(data[0])
@ -251,12 +251,12 @@ def flush():
t = getScrobbleObject(s)
artistss = "/".join(t["artists"])
artistss = "".join(t["artists"])
timestamp = datetime.date.fromtimestamp(t["time"])
entry = ",".join([str(t["time"]),artistss,t["title"]])
entry = "\t".join([str(t["time"]),artistss,t["title"]])
monthfile = open("logs/" + str(timestamp.year) + "_" + str(timestamp.month) + ".csv","a")
monthfile = open("logs/" + str(timestamp.year) + "_" + str(timestamp.month) + ".tsv","a")
monthfile.write(entry)
monthfile.write("\n")
monthfile.close()

View File

@ -18,7 +18,7 @@ for l in log:
(title,extraartists) = cleanup.findartistsintitle(title)
artists = list(set(artists + extraartists))
artistsstr = "/".join(artists)
artistsstr = "".join(artists)
timeparts = time.split(" ")
@ -28,7 +28,7 @@ for l in log:
timestamp = int(datetime.datetime(int(timeparts[2]),months[timeparts[1]],int(timeparts[0]),int(h),int(m)).timestamp())
entry = ",".join([str(timestamp),artistsstr,title,album])
entry = "\t".join([str(timestamp),artistsstr,title,album])
outputlog.write(entry)

1
logs/.gitignore vendored
View File

@ -1 +1,2 @@
*.tsv
*.csv