0

I'm trying to import a file that has multiple variables within it, each variable containing anywhere from 1 entry to about a hundred. so something like this:

[info]
name = Jon
number = 2
multiple_num = 
5
2
4
65
78
45

I've formatted this as an .ini file and used ConfigParser to read it in, however, unless I have the multiline values indented, ConfigParser gives me errors. So the above snippit of code will give me errors, yet this one will be fine.

[info]
name = Jon
number = 2
multiple_num = 
    5
    2
    4
    65
    78
    45

Is there a better way to do this that doesn't involve the user hand indenting every single line? Like I said, the data within some of the variables, while not enormous, would still be long enough to get annoying. Am I going about this the complete wrong way? Any help is appreciated!

Thanks,

Tyler

  • I know this isn't really what you're asking, but If you use a text editor like notepad++ you can just highlight all of the lines you want to indent and click tab to indent them all at the same time. – gommb Oct 19 '17 at 23:48

1 Answers1

0

You could create an array instead I would assume. However, the indenting is due to how Python's syntax works.

If you put the numbers inside an array, the indenting does not matter, but I would advice sticking to PEP8 style conventions.

SimZor
  • 24
  • 2