Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Parsing problem in Python

This is a discussion on Parsing problem in Python within the Python forums, part of the Web Development category; In a recent interview I was asked to write a small Python program to parse a file. The file had the following format: line line line START-METADATA FIELD1 FIELD2 FIELD3 ...

Go Back   Geeks Talk > Web Development > Python
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Python Python Programming Language - Tips, Tricks, Issues, Latest News, Python Resource and Python related topics can be discussed in this forum.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-04-2009
Junior Member
 
Join Date: Apr 2009
Location: New Jersey USA
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pkamath is on a distinguished road
Parsing problem in Python

In a recent interview I was asked to write a small Python program to parse a file. The file had the following format:
line
line
line
START-METADATA
FIELD1
FIELD2
FIELD3
END-METADATA
blah
blah
START-RESULTSET
Item1|Item2|Item3|Item4...
.....
...
END-RESULTSET

My Job was to parse the file, print all metadata fields on one line as header and then print the result set.

I had never used Python and my interviewer knew that. I guess they wanted to see how I approach the problem.

So I started thinking in Perl , which I have used before, and with some help from the interviewer and some on-line help, I collected the metadata in an array using the for loop and if statements.

Needless to say, I did not get the job. Unfortunately, I did not get any feed back also. So, I wanted to know how many ways there are to parse a file in Python. Since this was an interview I assumed I wouldn't get more than an hour to write the program and coming from a C/Java background I am wondering how should I have written the program.
Reply With Quote
Sponsored Links
Reply

  Geeks Talk > Web Development > Python

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
parsing data henri084 Java 2 06-18-2009 12:19 PM
what is Shell, Pearl, Python Scripting? chennaprashanth QTP 0 03-27-2008 08:44 AM
Python giribabu_vuppula Testing Issues 1 12-11-2007 11:14 AM
Working with XML in Python Lokesh M AJAX & XML 0 09-03-2007 07:03 AM
Need Forums or PERL/PYTHON kalayama Suggestions & Feedback 3 12-21-2006 09:14 PM


All times are GMT -4. The time now is 12:10 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved