Skip to content

Commit

Permalink
File reading and Writing
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Jul 8, 2019
1 parent d76e79d commit 030d887
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is rakesh and this is my first file handling program in Python
This is second line and i am learning new things in pythinthird line of the same program
10 changes: 10 additions & 0 deletions fileHandling/Create_Text_File.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#program to create Text File using Python
# made by : rakesh kumar
# Last Compiled on : 7/7/2018

file = open("Testing.txt","w")
file.write("This is rakesh and this is my first file handling program in Python \n")
file.write("This is second line and i am learning new things in pythin")
file.writelines("third line of the same program")
file.close()
print("File Generated please check")
11 changes: 11 additions & 0 deletions fileHandling/Find_lines_start_with_T.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#program to find out total number of "Project" word in any given test file
#made by : rakesh kumar
# made on : 07/07/2018

file = open(r"abcd.txt",'r')
count=0;
for line in file.readlines():
if line[0]=='T':
count+=1
file.close()
print("Total lines that start with alphabet 'T' :",count)
12 changes: 12 additions & 0 deletions fileHandling/Total_word_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#program to find out total number of "Project" word in any given test file
#made by : rakesh kumar
# made on : 07/07/2018

file = open(r"abcd.txt",'r')
words=lines=0
for line in file.readlines():
lines+=1
words+=len(line.split())
file.close()
print("Total Words in this File :",words)
print("Total Lines in this File :",lines)
2 changes: 1 addition & 1 deletion fileHandling/file_read.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file = open(r"C:\Users\acer\Desktop\PythonBox\pythonPrograms\fileHandling\abcd.txt",'r')
file = open(r"abcd.txt",'r')
data1 = file.read()
print(data1)
file.close()
11 changes: 11 additions & 0 deletions fileHandling/file_read_linewise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#program to find out total number of "Project" word in any given test file
#made by : rakesh kumar
# made on : 07/07/2018

file = open(r"abcd.txt",'r')
count=0;
for line in file.readlines():
if "Project" in line.split():
count+=1
file.close()
print("Total 'Project' term available :",count)

0 comments on commit 030d887

Please sign in to comment.