Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to update data in csv file using python

# importing the pandas library
import pandas as pd
  
# reading the csv file
df = pd.read_csv("AllDetails.csv")
  
# updating the column value/data
# df is a file, loc is a code to finde element in csv file, inside of []: 5 is a row and
# 'Name' is a column
df.loc[5, 'Name'] = 'SHIV CHANDRA'
  
# writing into the file (rewrite csv file)
df.to_csv("AllDetails.csv", index=False)
  
print(df)

# so if in your csv file at row 5 and column 'Name' data was Kallem Kruthik now its 
# gonna be SHIV CHANDRA
Comment

PREVIOUS NEXT
Code Example
Python :: python __repr__ 
Python :: python expand nested list 
Python :: create nested dictionary with user input in python 
Python :: appending objects to a list contained in a dictionary python 
Python :: how to create pyw file 
Python :: pandas count number of repetitions of each diferent value 
Python :: find nan values in pandas 
Python :: Display head of the DataFrame 
Python :: similarity imdex in python 
Python :: check multiple keys in python dict 
Python :: python lastmonth 
Python :: datetime column only extract date pandas 
Python :: one line if statement python without else 
Python :: df split into train, validation, test 
Python :: chrome webdrivermanager 
Python :: isoformat datetime python 
Python :: get column index pandas 
Python :: Python | Pandas DataFrame.where() 
Python :: how change column strin of list data type to list 
Python :: return mean of df as dataframe 
Python :: how to make a bill in python 
Python :: turtle graphics documentation 
Python :: json to argparse 
Python :: activate virtual environment 
Python :: random pick between given things python 
Python :: python sort an array 
Python :: python string interpolation 
Python :: calculate quantiles python 
Python :: Python: Extracting XML to DataFrame (Pandas) 
Python :: python how to add a string to a list in the middle 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =