Running into Errors creating a Python CSV file Concatenator script - Request HelpsteemCreated with Sketch.

in #python6 years ago (edited)

Figured it would be good to get more eyes on this. I'll gladly open source it for others once I get it working. Going to post this on StackExchange later but figured I'd give this shot first.

Usage should be fairly easy. Run the script, it'll prompt for a path, enumerate all the csv filenames in the path, and then cycle through each (ignoring the headers - assumed they are identical) constructing the output file.


TabError: inconsistent use of tabs and spaces in indentation

Result contains a list of file names and path contains a path on my system.

The problem code snippet is as follows. I've ensured there are no stray spaces and in the block but no joy.

for r in result:
    with open(path+r,'r') as f:
        header  =  f.readline()
        for line in f:
            fout.write(line)

As you can see below, it works fine if I don't place the With statement in the For loop. Probably making a rookie mistake and hoping it's something a veteran Python coder will pick up on easily.

I was working based on this question on StackExchange.

Sort:  

This is a test comment. Don't mind me.

Hey, your snippet works fine for me, but I may not have the full context. with in a for loop is not a problem, so I guess there's something else around this. You know how to find me on discord ;)

This exception means that the indentation is inconsistent in the script, is caused by the mixed use of tabs and spaces as indentation in the same script.

You can fix it simply changing all tabs to four spaces, or changing all the indentation to tabs.

Thanks, @zerocoolrocker. @crokkon took a look as well and essentially arrived at the same conclusion. I'll take a closer look at the indents and hopefully get this running today. I planned to use it to pull a @steemflagrewards consolidated report from the various logs but may opt to design a script to generate fresh data from the account's comments.

Great! @anthonyadavisii, I didn't know steemflagrewards project. I'm interested in being a flagger too. I'm going to investigate more about the project.

By the way it should be also possible to make a python script to find comments that are likely spam :)

YOU JUST GOT UPVOTED

Congratulations,
you just received a 30.83% upvote from @steemhq - Community Bot!

Wanna join and receive free upvotes yourself?
Vote for steemhq.witness on Steemit or directly on SteemConnect and join the Community Witness.

This service was brought to you by SteemHQ.com

Coin Marketplace

STEEM 0.31
TRX 0.11
JST 0.034
BTC 64852.72
ETH 3178.07
USDT 1.00
SBD 4.20