I am a student in my first python programming class in college and I am trying to figure out how to do my latest lab assignment. Could anyone just give my a hint on how to get a file (I know how to import it into the program) into dictionary form. We are creating an inventory database based on the following info:
item_id, item_name, price, quantity.

Seriously, even just a little hint would really help.

Recommended Answers

All 2 Replies

infile = open('InputFileName.txt', 'r')

for line in infile:
	#line is one string
	print line

I assume you want to create a
item_id: [item_name, price, quantity]
dictionary?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.