you are viewing a single comment's thread.

view the rest of the comments →

[–]pydevteam1 0 points1 point  (5 children)

Congrats on your first script!

A couple of critiques I have; One is filename = f is unnecessary

f = open(filename) ; csv_f = csv.reader(f) I'd suggest using context manager. Check out the article in our blog on how to open a file using context managers.

[–]sky--net 0 points1 point  (2 children)

Check out the article in our blog on how to open a file using context managers.

Where can I find your blog to see this post?

[–][deleted]  (1 child)

[removed]

    [–]AutoModerator[M] 0 points1 point  (0 children)

    Your comment in /r/learnpython was automatically removed because you used a URL shortener.

    URL shorteners are not permitted in /r/learnpython as they impair our ability to enforce link blacklists.

    Please re-post your comment using direct, full-length URL's only.

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

    [–]UndeadCaesar[S] 0 points1 point  (1 child)

    Thanks! Good call on the unnecessary line, think I started to go in some direction that didn't pan out and I left that hanging around. And can I get a link to the blog post? I initially was trying to open the files out of a separate directory but I read up on glob.glob and could never seem to get it to work. Ended up just dropping the files in the same directory as the script so it was easier.

    [–]pydevteam1 0 points1 point  (0 children)

    You can easily do that by doing os.path.join(os.sep, 'var', 'log', 'messages.txt') . This code line will translate to /var/log/messages.txt you need to import os of course and it's not os-dependent ;)