diff --git a/database.py b/database.py index 0f39188..80b3b07 100644 --- a/database.py +++ b/database.py @@ -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() diff --git a/lastfmconverter.py b/lastfmconverter.py index 8ad3cb3..9a36619 100644 --- a/lastfmconverter.py +++ b/lastfmconverter.py @@ -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) diff --git a/logs/.gitignore b/logs/.gitignore index afed073..a59cd8e 100644 --- a/logs/.gitignore +++ b/logs/.gitignore @@ -1 +1,2 @@ +*.tsv *.csv