receiving lists using config parser [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am quite new to using config parser and have just discovered that my INI file hasn't been used as expected. as you can see below it has been seeing every letter as an individual list but I want the list to be separated by the commas.
config = ConfigParser()
config.read('Airline Gates/JST.ini')
print(len(config['Airports']['YMML']))
Output > 79
.ini
[Airport]
YMML=[E11,E12,E13,E14,E15,E16,E17,E18,E19,E20,G41,G42,G43,G44,G45,G46,G47,G50,G51,G52]
I am very sorry for a poor explanation I am awful at explaining things but I will be happy to give you any more information. thanks!

Go through This video https://www.youtube.com/watch?v=jBwfq6UMxkY for better understanding of ConfigParser. For your current problem you can format the string value from ini file as per your need.
print(config['Airport']['YMML'].split(','))

Related

Why is this print function not outputting anything? (very new to python sorry) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I've just started learning python today and downloaded Pycharm, but even the simplest of commands aren't working at all. Could anyone help me with this? Thank you so much.
First use this link to check whether your config is correct. If you are running the correct .py file and it's not printing.
Go to Run>Edit Configurations And select the Emulate Terminal in output console as in the picture below then it should give you output.

Reading Excel files using python3 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am trying to read excel file using python to do some data analysis. The data file is located in the same folder as the python program. However, the code is giving a syntax error. Do not know why. Appreciate your help.
import pandas as pd
dataIn_df = pd.read_excel(r 'C:\Users\Jon\AppData\Local\Programs\Python\data\InputData.xlsx', sheet_name='InputData')
File "C:\Users\Jon\AppData\Local\Programs\Python\data\RateRegulator.py", line 54
dataIn_df = pd.read_excel(r 'C:\Users\Jon\AppData\Local\Programs\Python\data\InputData.xlsx', sheet_name='InputData')
^
SyntaxError: invalid syntax
There is an extra space between r and 'C:\... this is causing the SyntaxError.
r 'C:\Users\Jon\AppData\Local\Programs\Python\data\InputData.xlsx'
should be
r'C:\Users\Jon\AppData\Local\Programs\Python\data\InputData.xlsx'

Python - if SystaxError [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have problem with this if.
I found I can use in in if-statement.
if "log" in sys.argv[1:]
Syntax Error
If you don't show us the code surrounding the if-statement, we cannot know for sure what the problem is. If I were to make a guess however, I'd say you're missing a colon:
if "log" in sys.argv[1:]:
See the documentation for compound statements (like ifs):
Each clause header begins with a uniquely identifying keyword and ends with a colon

Trying to write a file, why am I getting "str object is not callable"? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm attempting to make a Dungeons and Dragons like game in Python, but I seem to have hit a wall. Whenever I run this code
file.write("Name:" (str(Char2)))
It returns
str object is not callable
You are using "file.write()" function. Inside parentheses you must put string. When you use "Name:" (str(Char2)) the Pythton see "Name:" as a function.
In other words, try this:
file.write("Name:{}".format(str(Char2)))
If you would like understand more see 6.1.3. Format String Syntax in this link: https://docs.python.org/3.4/library/string.html

Getting data from Google Maps python object [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I've gathered some data from Google Maps API but I'm stuck on getting out the LAT/LNG.
Creating object:
loc = self.google_maps.geocode(location)
I cannot traverse down this object:
pprint(loc)
I've tried:
loc.address_components
loc['address_components']
loc->address_components
loc.geometry
loc['geometry']
etc which all fail. This feels like such a simple question but I don't know they all fail to work
You should try:
loc[0]['address_components']
# ^ index the list
That's because your dict is contained in a list.
The same applies to other dictionaries that deeply nested:
loc[0]['address_components'][0]['long_name']
# or loc[0]['address_components'][1]['long_name'] for second nested dict

Categories