Q. What is Data Streaming and Buffering?
Data Streaming and Data Buffering is nothing but different methods of data transfer among client server architecture. As we know with HTTP Protocol, the client can either transfer data to the server that is uploading data to the server or sometimes client request some data from the server means downloading data from the server.
When the size of the data is more than some Megabytes to ensure the loss of data is minimal client and server can choose to transfer data in different chunks.
Now, when the server selects to send the data in chunks. so, at the time of download operations server chooses to transfer data in different chunks.
Now, when the client selects to send the data in chunks. so, at the time of uploading operations client choose to transfer data in different chunks.
Q. What is data Buffering?
Ans: When the requested data is completely accumulated inside the memory and then processed, we called it Buffering.
Q. What is Data Streaming?
Ans: when the data is processed at the time each chunk is received, we called it Streaming.
This is possible because request implements Readable Stream interface, and the content can be directly written to the file system using Writable Stream interface.Q. What is File?
A File is collection of data that is stored on various devices like Computer, Laptop, Mobile and Servers.
We can say that file is the fundamental unit of digital storage which is used to Store, organize and manage data permanently on secondary storage.
Q. Why do we require File in python?
A File is collection of data that is stored on various devices like Computer, Laptop, Mobile and Servers. Now just consider the following scenario in python.
Q. How to create File in python?
By using python inbuilt function open (filename, mode) we can create file in python.
How many modes file gets open in python?
- r: open for read operation but file must be present.
- w: open already existed file if present and override the content in it. but if file is not already present in that case it can create new file and write in it.
- a: open already present file in append mode. in this mode we append content at the end.
- r+: To perform both operation (read and write data into the file). This mode does not override the already present data, but you can change the data starting from the beginning of the file.
- w+: To perform both operation (write and read data). It overwrites the previous file if it is already present, it will truncate the file to zero length or create a file if it does not exist.
- a+: To append and read data from the file. It will not override already present data.
Problem Statement:
Write a python program to accept a file name from the user and perform the following operations as
1. Display the first N line of the file
2.Find the frequency of occurrence of the word accepted from the user in the file
The number of functions used in above code and their usage are as follows:
1. Strip() Function: If no character is specified in Strip() function then by default it removes all the starting and ending whitespaces.
For Example:
Case 1:
msg = " JSPM UNI "
afterstriped = msg . strip ()
print(afterstriped) # output is: "JSPM UNI"
Case 2:
msg = " ....,,,,nmsssss good sssrrt,,,...st"
afterstrip = msg . strip(".,nmsrt")
print(afterstrip) #output is: good
No comments:
Post a Comment