[Tutor] Importing data from a file.

Amit Saha amitsaha.in at gmail.com
Thu Mar 21 14:54:31 CET 2013


On Thu, Mar 21, 2013 at 11:43 PM, Shall, Sydney <sydney.shall at kcl.ac.uk> wrote:
> I have an elementary question provoked by another post today.
>
> 1. Is it the case that ALL imported data from a file is a string?
> 2. Does this therefor imply that said data has to be processed appropriately
> to generate the data in the form required by the program?

To the best of my knowledge, yes to both of your queries. Once you
have the element you want to process, you can make use of the type
converting functions (int(), float().. ) and use them appropriately.

> 3. Are there defined procedures for doing the required processing?

If you meant conversion functions, int() and float() are examples of
those. You of course  (most of the times) have to make use of string
manipulation functions (strip(), rstrip(), etc) to extract the exact
data item you might be looking for. So, they would be the building
blocks for your processing functions.

I hope that makes some things clear.

-Amit.

-- 
http://amitsaha.github.com/


More information about the Tutor mailing list