Python 3 A simple way to encrypt a file is to change all characters following a certain...

80.2K

Verified Solution

Question

Programming

Python 3

A simple way to encrypt a file is to change all charactersfollowing a certain encoding rule. In this question, you need tomove all letters to next letter. e.g. 'a'->'b', 'b'->'c',..., 'z'->'a', 'A'->'B', 'B'->'C', ..., 'Z'->'A'. Forall digits, you need to also move them to the next number. e.g.'0'->'1', '1'->'2', ..., '9'->'0'. All the other symbolsshould not be changed.

  1. Write a function encrypt with the following requirements:
  • the function takes a string argument, which is a filename.
  • read the csv file.
  • replace all characters uisng the rule above.
  • write the content to a new file named \"encrypted.csv\".
  1. Call the function with the file name\"business-price-indexes-june-2020-quarter-csv-corrected.csv\"

--2020-10-16 19:32:31--https://www.stats.govt.nz/assets/Uploads/Business-price-indexes/Business-price-indexes-June-2020-quarter/Download-data/business-price-indexes-june-2020-quarter-csv-corrected.csvResolving www.stats.govt.nz (www.stats.govt.nz)... 45.60.11.104Connecting to www.stats.govt.nz(www.stats.govt.nz)|45.60.11.104|:443... connected. HTTP requestsent, awaiting response... 200 OK Length: 11924606 (11M) [text/csv]Saving to:‘business-price-indexes-june-2020-quarter-csv-corrected.csv’business-price-inde 100%[===================>] 11.37M 4.56MB/sin 2.5s 2020-10-16 19:32:34 (4.56 MB/s) -‘business-price-indexes-june-2020-quarter-csv-corrected.csv’ saved[11924606/11924606]

Answer & Explanation Solved by verified expert
4.0 Ratings (716 Votes)
I have added the comments at every line for your understaningand also attaching the screenshots below for clarificationfor test sample i have used inputcsv file as input andoutput1csv file as output you can change those names as per yourrequirementimporting the writer and reader libraries for csv file in pythonfrom csv    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students