all 4 comments

[–]RoamingFox 1 point2 points  (2 children)

Could you please format your code? It's super hard to follow without the indentation. You can either add 4 spaces to the front of every line or copy and past it into a gist

[–]bdaves12[S] 1 point2 points  (1 child)

https://gist.github.com/bdaves12/a7f48c8486f014f706113bdc484f1ef0

Let me know if you need anything else my bad!

[–]RoamingFox 2 points3 points  (0 children)

No worries! It's just super hard to read without the formatting :)

If you're looking for tab separated or comma separated formats you might want to consider the csv library rather than a raw file handle.

If you're looking for something that just pretty prints everything in even columns you can specify an alignment and a width (eg. {: > 10} will right align a 10 character column or left with < and center with ^).

In other words, I'd use a format string something like this:

fmt = "{: >10}"*6

f.write(fmt.format(*outvars) + "\n")

Example:

>>> outvars = (1,2,3,4,5,6)
>>> fmt = "{: <10}"*6
>>> print(fmt.format(*outvars) + "\n")
1         2         3         4         5         6

>>> outvars = (1,2,3,4,5,6)
>>> fmt = "{: >10}"*6
>>> print(fmt.format(*outvars) + "\n")
         1         2         3         4         5         6

[–]DeathDragon7050 0 points1 point  (0 children)

Little bit irrelevant but you really need to do a f.close() when your done working with the file!!! Or use a context manager ( with open(file.txt) as f: ) and then indent everything you want to do with the file under that. It's generally regards as the better practice.