0

I have a pretty large .txt file with data (8MB) and the data lines are separated with the character F.

To analyze this data I need to replace the letter F with the Return command.

This is how my file looks:

-0.27,   -0.21,   9.56,   78.86,   47.79,   0.02F0.07,   -0.35,   9.47,   78.73,   47.74,   0.05F-0.20,   -0.43,   10.60,   79.00,   47.79,   0.07F-0.49,   -0.14,   10.44,   76.84,   47.70,   0.10.. and so on

This is how it should look:

-0.27,   -0.21,   9.56,   78.86,   47.79,   0.02
0.07,   -0.35,   9.47,   78.73,   47.74,   0.05
-0.20,   -0.43,   10.60,   79.00,   47.79,   0.07
-0.49,   -0.14,   10.44,   76.84,   47.70,   0.10
... and so on

I have a macOS and Windows available. Already tried it with Excel, but the file seems to be to large, Excel just crashes. Any advice?

Bruno
  • 11
  • 1
    https://notepad-plus-plus.org/ – GSerg Jun 14 '18 at 12:33
  • [How can you find and replace text in a file using the Windows command-line environment?](https://stackoverflow.com/q/60034/11683) – GSerg Jun 14 '18 at 12:35
  • Agree: Notepad++ then in find/replace enable 'use special character', then replace F with \r\n (if you're on windows) or with \n if you're on *nix – DDS Jun 14 '18 at 12:46
  • I just tried it with notepad++ and the setting DDS supposed. It worked! Thanks you! Is there a way to set this question as solved? – Bruno Jun 14 '18 at 12:49

3 Answers3

0

Try EditPad Lite on Windows. It's a notepad, that is able to handle big files.

You have to enable regular expressions (search->search options) to work correctly. After that you can open the search and replace F with \r\n (new line operator).

ADarkHero
  • 48
  • 8
0

In MacOS, give this a try.

Using translate characters command

tr F '\n' < input.txt > output.txt

The result will be stored in a separate file. If no new file needed, just remove > output.txt from the command, it will display the result in the console.

Using stream editor command

sed -i '' $'s/F/\\\n/g' test.txt

The sed command will do the same operation with the use of regex. This replace the contents in the original file. To create a backup of the file, give the extension in the argument i (Ex : -i '.backup' creates a file backup test.txt.backup).

For more info, do man tr and man sed in your mac terminal.

Vignesh Raja
  • 5,592
  • 1
  • 25
  • 32
0

You can use TextEdit on a Mac. Use the find and replace option. It is very fast in the test I tried. I used a 5 M file and it ran in a few seconds. Refer to the previous question in Ask Different 'How to use find and replace to replace a character with new line' to see how to get newlinein character in find and replace option.

Natsfan
  • 3,034
  • 3
  • 17
  • 26