loadtxt doubt
Title
Question
sir , U have used only one variable to read data.txt but it contains 3 columns
x=loadtxt("data.txt",unpacked=true,delimiter=":")
how three sequences are stored only in variable.
in the video prevously we used L and M variables as
L,M=loadtxt("pendulum_semicolon.txt",unpacked=True,delimiter=";")
Python-3.4.3 Loading-Data-From-Files 09-10 min 0-10 sec
Answers:
When you run x=loadtxt("data.txt",unpack=True,delimiter=":") all the columns of the file are stored in the single variable as a array. Each column in the file becomes a row in the array.
You can also do x,y,z = loadtxt("data.txt",unpack=True,delimiter=":"), this will store the first column in x, second column in y and third column in z.
When you run L,M=loadtxt("pendulum_semicolon.txt",unpack=True,delimiter=";") individual column is stored in separate variable. Here, 1st column from </span>pendulum_semicolon.txt is stored in L and 2nd column is stored in M.
Login to add comment