'Convert a big table of value into string [closed]
I have a table of value that i want to insert in my python code as a string :
I tried this but not working :
str(3.354219E-03 3.584506E-03 3.830603E-03 4.093597E-03 4.374646E-03
4.674992E-03 4.995957E-03 5.338959E-03 5.705510E-03 6.097227E-03
6.515837E-03 6.963188E-03 7.441252E-03 7.952137E-03 8.498098E-03
9.081543E-03 9.705044E-03 1.037135E-02 1.108341E-02 1.184435E-02
1.265753E-02 1.352655E-02 1.445522E-02 1.544766E-02 1.650823E-02
1.764162E-02 1.885282E-02 2.014718E-02 2.153040E-02 2.300859E-02
2.458826E-02 2.627639E-02 2.808042E-02 3.000831E-02 3.206855E-02
3.427025E-02 3.662310E-02 3.913749E-02 4.182451E-02 4.469601E-02
4.776465E-02 5.104398E-02 5.454845E-02 5.829352E-02 6.229571E-02
6.657268E-02 7.114329E-02 7.602769E-02 8.124744E-02 8.682555E-02)
Or another way would be to put quotation marks at the beggining and end of line but it's take too much time. If there are some options in Vim or Notepad i would be glad to here about it.
Solution 1:[1]
One way would of course to do it programmatically and immediately split your string so that you retrieve the desired table. If you read a multi-line string, you should use three quotation marks """.
If you are looking for a way to do it in a text editor, here are two solutions that work in VS Code (and many more editors)
- Column-selection mode. Decently fast, because your inputs are all the same length. You can highlight all rows and then just add quotes accordingly.
- Reg-ex replacement. You can use the following regex, see explanations here. Note that I highlighted the reg-ex mode (next to "1 of 200").
Regardless of the method, by using three quotation marks here as well, Python should be able to read your string including the "inner" quotation marks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

