Python Forum

Full Version: How to map character to integer in python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
suppose we have one csv file containing 2*2 matrix like
Name Age Problem
Rajeev 30 Y
Kumar 32 N
Madan 31 Y
I want to convert Y to 1 and N to 0 into csv file by using python.
1. Open the file for reading, open output file for writing
2. Read the each line and parse it, replacing Y/N values
3. Write the new line in the output file

this can be done with basic file operations or you can use csv module
also tutorial on working with files

and by the way this is not 2x2 matrix