I have in a textdocument a long, uninterrupted stream of bits, about 2700.
I would like to import that bitstram in Calc but cut it up in chunks of 40 bits wide.
So each cell should hold 40 bits going from A1 --> An.
I'm very new to Calc, could someone give me some guidance?
[Solved] Split bitstream into 40-bit chunks
-
- Posts: 2
- Joined: Sat May 20, 2023 9:17 pm
[Solved] Split bitstream into 40-bit chunks
Last edited by MrProgrammer on Fri Jun 02, 2023 6:12 am, edited 2 times in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 4.1.12 on Windows 10
Re: Split bitstream
How is the thing you are calling a bit stream represented in the Writer document?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
-
- Posts: 2
- Joined: Sat May 20, 2023 9:17 pm
Re: Split bitstream
An uninterrupted sequence of 1 and 0, no spaces or other characters.
OpenOffice 4.1.12 on Windows 10
Re: Split bitstream
Thus you mean characters, not bits, and the stream is a string?
To split a long string in chunks of equal length you need to calculate the starting positions. Then the MID() function is applicable. It can be completed in different ways, either by a formula for array evaluation or by single-cell-formulas. (Many variants.)
See attached example.
To split a long string in chunks of equal length you need to calculate the starting positions. Then the MID() function is applicable. It can be completed in different ways, either by a formula for array evaluation or by single-cell-formulas. (Many variants.)
See attached example.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Split bitstream
Paste the string to a cell in Calc, then replace (\d{40}) by $1; with regular expressions checked, format as many cells as text as necessary before using Text to columns with ; as separator, and copy the result to one column using the Transpose option.
AOO 4.1.15 & LO 24.2.2 on Windows 10
Re: Split bitstream
Hallo
Code: Select all
sed 's/.\{,40\}/&\n/g' bitstream.txt > bitstream_with_breaks.txt
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
- MrProgrammer
- Moderator
- Posts: 4904
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Split bitstream
Open the text document with Writer.Tailgunner wrote: ↑Sat May 20, 2023 9:21 pm I have in a textdocument a long, uninterrupted stream of bits, about 2700. I would like to import that bitstram in Calc but cut it up in chunks of 40 bits wide.
• Edit → Find & Replace → More options → ✓ Regular Expressions → Search for [01]{40} → Replace with &\n → Replace All
• Uncheck Regular expressions → Close
• Edit → Select All
• Edit → Copy
Open a Calc document.
• Edit → Paste Special → Unformatted Text → OK
• At the bottom, below Fields, click Standard
• Change the Column Type to Text → OK.
[Tutorial] Text to Columns
If you need any additional assistance attach a Writer document with the long bit string (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the document itself). I will not help further unless you attach.
[Tutorial] Ten concepts that every Calc user should knowTailgunner wrote: ↑Sat May 20, 2023 9:21 pm I'm very new to Calc, could someone give me some guidance?
If this solved your problem please go to your first post use the Edit ☐ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).