Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to map character to integer in python
#1
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.
Quote
#2
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
https://python-forum.io/Thread-Basic-Files

and by the way this is not 2x2 matrix
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 128 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  python cache for small integer Uchikago 1 457 Jun-27-2019, 05:32 PM
Last Post: ichabod801
  Error when entering letter/character instead of number/integer helplessnoobb 2 479 Jun-22-2019, 07:15 AM
Last Post: ThomasL
  Replace changing string including uppercase character with lowercase character silfer 11 958 Mar-25-2019, 12:54 PM
Last Post: silfer
  Python function that uses a word as the encryption key, rather than an integer wak_stephanie 4 1,173 Aug-31-2018, 12:16 PM
Last Post: perfringo
  How to sum up the elements of an integer using python split/join? mohanraj1986 5 730 Aug-27-2018, 09:13 AM
Last Post: perfringo
  How to convert character to integer in python rajeev1729 2 1,307 Oct-03-2017, 04:30 PM
Last Post: nilamo
  SyntaxError: unexpected character after line continuation character Saka 2 13,105 Sep-26-2017, 09:34 AM
Last Post: Saka

Forum Jump:


Users browsing this thread: 1 Guest(s)