Skip to content

Commit

Permalink
Better log output, fix writing to file.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniaelek committed Mar 9, 2019
1 parent cdd4e0e commit 348024c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion export/artists.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ func GetArtists(user string, apiKey string) (artists []Artist, err error) {
for _, a := range ts {
cnt, err := strconv.Atoi(a.Playcount)
if err != nil {
continue
log.Printf("Error fetching play count for aritst %s\n", a.Name)
cnt = 0
}
artist := Artist{
Name: a.Name,
Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"bufio"
"flag"
"fmt"
"lastfmuserexport/export"
"log"
"os"
Expand Down Expand Up @@ -154,9 +154,11 @@ func SaveCsvFile(csv []string, filename string) error {
return err
}
defer f.Close()
w := bufio.NewWriter(f)

for _, line := range csv {
w.WriteString(line + "\n")
fmt.Fprintln(f, line)
}
defer f.Close()

return nil
}

0 comments on commit 348024c

Please sign in to comment.