Identi.ca Identi.ca
  • Login
  • Public

    • Public
    • Groups
    • Featured
    • Popular

Conversation

Notices

  1. Sidney Charles Witherjay Sidney Charles Witherjay Python , Bourne Again SHell group

    I'm having a brain block; I need the quickest way to split the text in a file into groups of 10 letters. !bash !python

    about 9 months ago from Afficheur
    • Samat K Jain Samat K Jain

      @ajpaulson /usr/bin/split -b10

      about 9 months ago
    • Sidney Charles Witherjay Sidney Charles Witherjay Samat K Jain

      @samatjain thank you! I didn't even know that existed! I owe you some internet points

      about 9 months ago
    • Sidney Charles Witherjay Sidney Charles Witherjay

      now I just need to get it all back into one file with spaces at each split

      about 9 months ago
    • Sidney Charles Witherjay Sidney Charles Witherjay Samat K Jain

      @samatjain nevermind, using sed (motherfuckers act like they forgot about sed)

      about 9 months ago
    • Arne Babenhauserheide Arne Babenhauserheide

      @ajpaulson ten = []; while text: ten.append(text[:10]); text = text[10:]

      about 9 months ago
    • Sidney Charles Witherjay Sidney Charles Witherjay sed , Arne Babenhauserheide

      @arnebab Thanks but I solved it with a !sed one liner: sed 's/.\{10\}/& /g' input.txt > output.txt

      about 9 months ago
    • Arne Babenhauserheide Arne Babenhauserheide

      @ajpaulson but that’s off the question! (mock-angry :) ) sure, sed is shorter :)

      about 9 months ago
    • Sidney Charles Witherjay Sidney Charles Witherjay Arne Babenhauserheide

      @arnebab true, I specified bash and python and used neither :p sometimes you gotta break the rules

      about 9 months ago
    • Marc Rintsch Marc Rintsch Arne Babenhauserheide

      @arnebab Shorter and more efficient: ten = [text[i:i+10] for i in xrange(0, len(text), 10)]

      about 9 months ago
    • Arne Babenhauserheide Arne Babenhauserheide Marc Rintsch

      @bj that’s nice! thanks! … 140 letter algorithms :)

      about 9 months ago

Site notice

  • API
  • Status

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

Identi.ca is a microblogging service brought to you by Status.net. It runs the StatusNet microblogging software, version 1.1.0-alpha1, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All Identi.ca content and data are available under the Creative Commons Attribution 3.0 license.

Switch to mobile site layout.

Built in Montreal