Thank you for MATLAB, but in any worst language, I want you to do the following:
I have a csv file with 1 row and 75 columns, but I want to read the values into a 3 * 25 matrix.
For example, the file value is
2,4,1,3,5,1,4,5,8, ..., 3,2,9
If we have 75 values, we want to make this a 3 by 25 matrix (three in a row).
2 3 4 ... 3
4 5 5 ... 2
1 1 8 ... 9
How can I achieve this using a for statement?
There is also a powerful work to define 75 variables and put them one by one in the array, but the amount of sentences will be ridiculous, so
I want you to think of a smart way.
Answer # 1
You can use any worst language
Do not accept questions about this code.
import numpy as np arr = np.loadtxt ('src.csv', delimiter = ',', dtype = np.int) np.savetxt ( 'dst.csv', arr.reshape (3, 25), fmt = '% d' )
In general terms, can it be realized in most languages by the following method?
src = read data (src is an array of 75 elements) for y in 0 ~ 3: for x in 0 ~ 25: Output y * 25 + xth element of src Output blank Output line break
Of course there are writing methods suitable for each language, but
If you can't come up with it, you can only write in a muddy manner.
At least "the amount of text is outrageous".
- java - i don't know how to create a common class to start a gallery or camera (how to use startactivityforresult)
- python - i want to create a graph with a range for each value
- java - meaning of return value of onoptionsitemselected
- how to create comma separated array in java
- how should i create a web application in java (fw is spring) that conforms to the web 3 layer structure?
- java - please tell me how to write the value of list to a variable
- java - i want to create an array of abstract classes
- java - i want to be able to log in if the db value and the entered value match when i log in
- java - i want to create a program that displays a circle animation that reflects when it hits the edge of a window
- java - how to use if statement with the value specified in servlet in jsp?
- java - the value of the local variable rccar1 cannot be executed because it is not used
- java - about passing by value and passing by reference
- java - i want to save the value with shared preferences
- java - what is the value of the field processed in the method
- java - i want to create a quick sort program that uses arraylist
- java - display maximum value, minimum value, and average from multiple integers
- java - the value specified by select button is not registered in db
- python - i want to automatically enter a value in create view of django
- java - how to connect to db using bind variables create table
- displaying the initial value of a form using java servlet and jsp
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- python - importerror: cannot import name md5 error cannot be resolved