Hello, I'm still very new to python, and I'm tyring to figure out how I would parse data from an input file.
Here is what the input file would look like.

B 128.9 hello 2918.1 hi 2938.2 world
H 12.2 India 218.6 Lost 29.9 Place
C 28.3 Watch 28.4 Found 293.9 Palace
...
...
...

I'm trying to seperate the first capitalized letter into a command variable, and the 128.9, "hello" into a dictionary together. Then do the same for 2918.1 and "hi" into the next dictionary level. so on and so on. until I find the next command and take that data near it for the other function. How would I be able to do this? I just can't figure out how to seperate them all. Thanks!

Recommended Answers

All 2 Replies

Can you provide the expected output?
What is a command variable?
What is a dictionary level?
What I understand is that the first two lines should be stored as:

data={"B":(
    (128.9,"hello"),
    (1918.1,"hi"),
    (2938.2,"world"),
    ),
      "H":(
    (12.2,"India"),
    (218.6,"Lost"),
    (29.9,"Place"),
    )
}

Did you not ask this in C++? :S Choose which language you're going to work in.. Better still, build it in one language and make an interface in different languages? Don't re-invent code in multiple languages, unless you absolutely have to.

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.