Running into Errors creating a Python CSV file Concatenator script - Request Help by anthonyadavisii

View this thread on steempeak.com
· @anthonyadavisii · (edited)
$0.62
Running into Errors creating a Python CSV file Concatenator script - Request Help
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.

![](https://cdn.steemitimages.com/DQmbKohWsWgFitjg6odaHz1xpWvwE4e6PnZ1SsZEnaArUwV/image.png)
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.


![](https://cdn.steemitimages.com/DQme4GKUFQnmvABAqB13pRnRssrS5V4HsaEh4rMta3Dh9AR/image.png)

I was working based on this [question](https://stackoverflow.com/questions/2512386/how-to-merge-200-csv-files-in-python) on StackExchange.
👍  , , , , , , , , , , , , ,
👎  , , , , , , , , , , , , , , , , , , ,
properties (23)
post_id52,482,779
authoranthonyadavisii
permlinkrunning-into-errors-creating-a-python-csv-file-concatenator-script-request-help
categorypython
json_metadata"{"tags": ["python", "scripting", "coding", "troubleshooting", "busy"], "links": ["https://stackoverflow.com/questions/2512386/how-to-merge-200-csv-files-in-python"], "community": "busy", "app": "busy/2.4.0", "format": "markdown"}"
created2018-06-10 15:11:54
last_update2018-06-10 15:13:42
depth0
children6
net_rshares234,801,888,677
last_payout2018-06-17 15:11:54
cashout_time1969-12-31 23:59:59
total_payout_value0.511 SBD
curator_payout_value0.110 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,315
author_reputation126,215,040,536,555
root_title"Running into Errors creating a Python CSV file Concatenator script - Request Help"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars0
author_curate_reward""
vote details (34)
@crokkon ·
$0.04
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 ;)
properties (22)
post_id52,499,011
authorcrokkon
permlinkre-anthonyadavisii-running-into-errors-creating-a-python-csv-file-concatenator-script-request-help-20180610t173848485z
categorypython
json_metadata"{"tags": ["python"], "app": "steemit/0.1"}"
created2018-06-10 17:38:48
last_update2018-06-10 17:38:48
depth1
children0
net_rshares0
last_payout2018-06-17 17:38:48
cashout_time1969-12-31 23:59:59
total_payout_value0.031 SBD
curator_payout_value0.010 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length199
author_reputation75,470,595,669,689
root_title"Running into Errors creating a Python CSV file Concatenator script - Request Help"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@neutralizer ·
$0.07
This is a test comment. Don't mind me.
properties (22)
post_id52,551,290
authorneutralizer
permlinkre-running-into-errors-creating-a-python-csv-file-concatenator-script-request-help-20180611t031452
categorypython
json_metadata{}
created2018-06-11 03:15:00
last_update2018-06-11 03:15:00
depth1
children0
net_rshares0
last_payout2018-06-18 03:15:00
cashout_time1969-12-31 23:59:59
total_payout_value0.066 SBD
curator_payout_value0.006 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length38
author_reputation602,559,586,074
root_title"Running into Errors creating a Python CSV file Concatenator script - Request Help"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@zerocoolrocker ·
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.
properties (22)
post_id52,813,631
authorzerocoolrocker
permlinkre-anthonyadavisii-running-into-errors-creating-a-python-csv-file-concatenator-script-request-help-20180613t030153737z
categorypython
json_metadata"{"tags": ["python"], "app": "steemit/0.1"}"
created2018-06-13 02:31:48
last_update2018-06-13 02:31:48
depth1
children2
net_rshares0
last_payout2018-06-20 02:31:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length252
author_reputation3,841,001,214
root_title"Running into Errors creating a Python CSV file Concatenator script - Request Help"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@anthonyadavisii ·
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.
properties (22)
post_id53,129,870
authoranthonyadavisii
permlinkre-zerocoolrocker-re-anthonyadavisii-running-into-errors-creating-a-python-csv-file-concatenator-script-request-help-20180615t164359052z
categorypython
json_metadata"{"users": ["zerocoolrocker", "crokkon", "steemflagrewards"], "tags": ["python"], "app": "steemit/0.1"}"
created2018-06-15 16:44:03
last_update2018-06-15 16:44:03
depth2
children1
net_rshares0
last_payout2018-06-22 16:44:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length351
author_reputation126,215,040,536,555
root_title"Running into Errors creating a Python CSV file Concatenator script - Request Help"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@zerocoolrocker ·
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 :)
properties (22)
post_id53,133,932
authorzerocoolrocker
permlinkre-anthonyadavisii-re-zerocoolrocker-re-anthonyadavisii-running-into-errors-creating-a-python-csv-file-concatenator-script-request-help-20180615t175933390z
categorypython
json_metadata"{"tags": ["python"], "users": ["anthonyadavisii"], "app": "steemit/0.1"}"
created2018-06-15 17:29:30
last_update2018-06-15 17:29:30
depth3
children0
net_rshares0
last_payout2018-06-22 17:29:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length256
author_reputation3,841,001,214
root_title"Running into Errors creating a Python CSV file Concatenator script - Request Help"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steemhq ·
re-anthonyadavisii-running-into-errors-creating-a-python-csv-file-concatenator-script-request-help-20180613t082306325z
![YOU JUST GOT UPVOTED](https://www.steemhq.com/CommunityBotUpvote.png)

**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](https://steemit.com/~witnesses) or directly on [SteemConnect](https://steemconnect.com/sign/account-witness-vote?witness=steemhq.witness&approve=1 "This link will take you away from steemit.com") and join the [Community Witness](https://www.steemhq.com/witness).
![](https://steemitimages.com/0x0/https://www.steemhq.com/steemhq_voting.gif)

This service was brought to you by [SteemHQ.com](https://www.steemhq.com)
properties (22)
post_id52,839,862
authorsteemhq
permlinkre-anthonyadavisii-running-into-errors-creating-a-python-csv-file-concatenator-script-request-help-20180613t082306325z
categorypython
json_metadata"{"app": "communitybot/1.1.0"}"
created2018-06-13 08:23:06
last_update2018-06-13 08:23:06
depth1
children0
net_rshares0
last_payout2018-06-20 08:23:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length667
author_reputation4,222,362,886,512
root_title"Running into Errors creating a Python CSV file Concatenator script - Request Help"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000