Monday, September 9, 2013

python saving information from text data

python saving information from text data

this is my Code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import re
#read information
f = open ("/home/ibrahim/Desktop/Test.list")
text = f.read()
#show existing companys
for line in open('/home/ibrahim/Desktop/Test.list'):
company, founding_year, number_of_employee = line.split(',')
print "Company: %s" % company
#User chooses a company he wants to know more about
CompanyIndex = raw_input('\n<Choose a company you want to know more
about.>\n\n<Insert a companyspecific-number and press "Enter" .>\n')
#Companyspecific information is getting revealed
if CompanyIndex == '1':
print #company1,founding_year1,number_of_employee2
elif CompanyIndex == '2':
print #company2,founding_year2,number_of_employee2
elif CompanyIndex == '3':
print #company3,founding_year3,number_of_employee3
else:
print 'Your input is not correct..'
My aim is that the user of this program can choose a specific Company he
wants to find out more about, like for example the year this company
started and the number of employees Example: Companyname = Chef, year the
company started = 1965 and number of employees = 10 I don't want to print
more than the company's name, because the information in the future will
contain more than just the founding year and the number of employees ;) it
would be pretty confusing to see so much information ^^ Now my Problem is,
that I do not know how to save the Information I received about the
company and how to print those out in this block:
if CompanyIndex == '1':
print #company1,founding_year1,number_of_employee2
elif CompanyIndex == '2':
print #company2,founding_year2,number_of_employee2
elif CompanyIndex == '3':
print #company3,founding_year3,number_of_employee3
else:
print 'Your input is not correct..'

No comments:

Post a Comment