Coder Social home page Coder Social logo

binaryfilesearch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gjdv hannob

binaryfilesearch's Issues

Possible to relax requirement to use 'with'?

What do you think about moving the code for _enter_() to the end of _init_()? I don't always want to indent my entire program, but rather just store the open file in a variable. As written, I need to call _enter_() explicitly, which feels a bit strange.

Super library by the way. Just what I was looking for.

Search for string keys of varying length

The sort suggested by the current README does not make BinaryFileSearch work on keys (first column) of varying length.

I figured out this is because the module expects strict prefixes to come first, while bash sort puts them at the end. For example, the module expects

ban
banana
cat

whereas sort produces

banana
ban
cat

We can obtain the expected sort by first padding the keys with whitespaces (assuming the keys don't have whitespaces or characters strictly before in ASCII) in awk, and removing them after sorting:

awk 'BEGIN {FS=OFS=","} {s = sprintf("%*s",N-length($1),""); print $1 s,$2}' input.csv \
 | LC_ALL=C sort --key=1 --field-separator=','
 | sed 's/ //g' > output.csv

where N is the max size of keys, which can be obtained using:

cut -d ',' -f 1 input.csv | wc -L

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.