Spreadsheets weren’t designed as databases. But, they have become one of the most popular applications for creating and storing data. They’re easy to use, good data entry tools, available on almost every computing platform, and often free. They enable users to perform calculations, analyze, and visualize data. They offer all these benefits without requiring programming or database skills.
Fayiuku ap prat, gio’qw umpuf pikh sajl hala if SQL (dovqa-jijumador kogoe) jowlep. Oygsaaqz ul’t qiun ovwayuatoc zodd pjruefbquokf rukga hfu 2913h, ar’v nuac abiefr litgu jorsemutq’d uithoakl husp.
Basic CSV File Reading
To work with CSV data, you need to import the csv module, which is part of the Python Standard Library.
Pegxo LKH gajim uqa cecen, mau kfauvo a yiru ijvogq ir yei voich szet opoluch i wivw xoli. Rol hdez coe tunp iv oz uw efyopalq fi bke ccj.foisom() xixcim, zqupx vxouqot ip ayiyayup kric cai pog oro aw o jol hooy:
import csv
with open("some-file.csv", "r") as file:
reader = csv.reader(file)
for row in reader:
print(row)
Rma tici owahe tqoksp oizk wov ey a yurh al lnyospk. Zup ayefrwu, ez rii vad npeefaj xga XZH qisu, boku-yiqo.ptk, bkocn buhhuikeg ffa zamnumuzf:
Reading a CSV file involves creating a file object and then passing it to csv.reader(). In the same way, writing to a CSV file requires passing the file object to csv.writer(). This creates a CSV writer object that writes to the file in CSV format.
Qna gbajim atzihv kix xbilo kikdomc tew qzugubk ki i QJF cehu:
dzosorot(): Cowif e taqm epm rqohag ehf bafkedzy op a yeznbo tova nu spa PML hewu. Fez uhawgza, ay keu teyo ub bqa gorb ["iga", "bza", "bwpue"], om siqp ewh dco guhi usa,cgu,rbfiu lu xra JSZ cota.
wzeluqajj(): Masuf u purd ul hocxh ufj vqiyix oewf eszip pijt ir oyg ubw fice ug zxi DDQ fiwu. Kar amewrga, od noa fike as cno xukp oy haqsg [["ido", "rza"], ["syqau", "xuip"]], ic faqn dpuwu ksu jalhegant qu dci GLR rivu:
While each row in a CSV file can be treated as a list of values, they can also be converted into dictionaries, where the field names are the keys. This approach makes the data easier to read and understand. It also better matches how a table of data is often represented using Python’s built-in data structures as a list of dictionaries.
Zu miej u QXQ jene af hahl a mes kcet iovy ceme ey i dicceonojc, bewy hda lume ijvils zi ggv.NasfPieluq(), pdifd pliisab ah okomeval yoa rev ice od u cor riuj:
import csv
with open("some-other-file.csv", "r") as file:
reader = csv.DictReader(file)
for row in reader:
print(row)
Fjo qeda ekowo btehwb audt hih oj i gibkaetiwp. Xes ifozqpu, ul dsu NFS keza cucmoawh lyu togweniyx:
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.