Git Product home page Git Product logo

Comments (6)

daviewales avatar daviewales commented on May 23, 2024

Another example to consider is saving a frequency sheet as .fixed. For example, suppose you have colours.csv:

colours
blue
blue
blue
green
green
green
green
orange
purple
red
red

The Frequency sheet looks like this:
image

If you save it as fixed, you get:

colours   count   percent   histogram                                
green           4     36.36 ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇   
blue            3     27.27 ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇             
red             2     18.18 ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇                      
orange          1      9.09 ▇▇▇▇▇▇▇▇▇                                
purple          1      9.09 ▇▇▇▇▇▇▇▇▇                                

Once again, there are three extra spaces inserted. However, because the count and percent are numeric, they are right-aligned. Due to the right-alignment, the three extra spaces are added on the left side of the numeric values, which causes them to not be aligned with the column headers. This breaks the fixed loader:

image

from visidata.

anjakefala avatar anjakefala commented on May 23, 2024

Most recent fixed width saver issue: #1849

from visidata.

daviewales avatar daviewales commented on May 23, 2024

from visidata.

daviewales avatar daviewales commented on May 23, 2024

Hmm... I'm wondering if getMaxWidth is being used for conflicting purposes. Here, we want the max width of the data, but it looks like getMaxWidth is trying to get a max display width. Also, I'm wondering if this is where the extra spaces come from:

w = max(w, nlen)+2

from visidata.

daviewales avatar daviewales commented on May 23, 2024

I've added a draft PR with some experimentation. (#2257) It's a lot closer to what I expect. It separates columns by a single space. However, when reading, that space is still interpreted as data, so we still grow by a single space per round trip. I think the saver is good to go, but the loader needs some work to prevent it loading the column separation space as data. I also switched it to use the real max width, rather than the max width of the window. This will be slow, but I think it's OK, because it will only run when saving, and I think most people would want to save all the data without truncating it.

from visidata.

daviewales avatar daviewales commented on May 23, 2024

The PR above is ready for initial review.

from visidata.

Related Issues (20)

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.