<jupyter_start><jupyter_text>Input and Output<jupyter_code>import json as json
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import random as random
%matplotlib inline
#mkdir newfolder<jupyter_output><empty_output><jupyter_text>Txt file - ```with open ()``` method<jupyter_code>mkdir data
with open('data/test.txt', 'w')as file:
    for k in range(100):
        file.write("it is your "+ str(k) + "th turn! \n")<jupyter_output><empty_output><jupyter_text>- ```open()``` and ```close()``` method<jupyter_code>txtfile = open("data/textdata.txt",'w')
for i in range (1000):
    '''check even or odd'''
    if i%2 ==0:
        txtfile.write(str(i) + "|It is even \n")
        
        '''check above or below 500'''
        if i<500:
            txtfile.write(str(i) + "|It is below 500 \n")
        else:
            txtfile.write(str(i) + "|It is above 500 \n")
            
    else:
        txtfile.write(str(i) + "|It is odd \n")
        
        '''check above or below 500'''
        if i<500:
            txtfile.write(str(i) + "|It is below 500 \n")
        else:
            txtfile.write(str(i) + "|It is above 500 \n")
            
txtfile.close()<jupyter_output><empty_output><jupyter_text>- uploading/reading text file<jupyter_code>with open('data/textdata.txt','r') as f:
    i = 0
    for line in f:
        print(line)
        if i >10:
            break
        i = i+1<jupyter_output>0|It is even 

0|It is below 500 

1|It is odd 

1|It is below 500 

2|It is even 

2|It is below 500 

3|It is odd 

3|It is below 500 

4|It is even 

4|It is below 500 

5|It is odd 

5|It is below 500<jupyter_text>JSON file<jupyter_code>Data = []
for k in range(1000):
    Data.append({"x": np.random.uniform(0,10),\
        "y": np.random.uniform(0,20),\
        "z" : np.random.uniform(0,10)})
Data[101:105]<jupyter_output><empty_output><jupyter_text>- Save data to a JSON file<jupyter_code>mkdir data
with open("data/sample_data.json", 'w')as f:
    json.dump(Data,f)<jupyter_output><empty_output><jupyter_text>- Upload data from JSON file<jupyter_code>with open("data/sample_data.json","r")as f:
    uploaded_data = json.load(f)
uploaded_data[0:2]<jupyter_output><empty_output><jupyter_text>CSV file<jupyter_code>DF = pd.DataFrame(Data)
DF.head()<jupyter_output><empty_output><jupyter_text>- Save data to a CSV file<jupyter_code>DF.to_csv("data/sampledata.csv")<jupyter_output><empty_output><jupyter_text>- Upload data from a CSV file<jupyter_code>uploaded_data = pd.read_csv("data/sampledata.csv")
uploaded_data.head()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup