<jupyter_start><jupyter_text>Manage Files Starting to create something real.Creating and reading things (txt filens, and cvs). A text file can be thought of as a sequence of lines<jupyter_code>## Opening a file
handle = open('filename', mode='r')
fhand = open('file.txt')
#How read a file
xfile = open('file_name.txt')
#elegant way to read an opened file
for x in xfile:
    print(x)
       
#Continuing Lines in a File
#How count line in a file TXT with python
fhand = open('file_name.txt')
count = 0
for line in fhand:
    count = count + 1
print('Line Count:', count)
#Searching through a File
fhand = open('file_name.txt')
for line in fhand:
    if line.startswith('From:'):
        print(line)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10714285714285714, 'fraction_numerical': 0.0027472527472527475, 'mean_word_length': 4.360294117647059, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '371767', 'license': 'MIT', 'n_tokens_mistral': 247, 'n_tokens_neox': 240, 'n_words': 93, 'path': '2022/Python-FreeCodeCamp/chapter_7.ipynb', 'repo_name': 'millennialseb/EDU_python', 'size': '728'}