Code Monkey home page Code Monkey logo

csv.vim's Introduction

Hello there, I am Chris

I work at Ataccama as Senior Platform Consultant. My spare time I nowadays mostly spend on Vim where I am one of the maintainers now and help to lead the projects direction. I am also quite active within the greater Vim community with my own Vim plugins, Reddit and Stackoverflow.

Outside of work, I am a pretty boring person ๐Ÿ™ˆ. I go hiking, like travelling, photography and spend my time with my family.

image

csv.vim's People

Contributors

0x6a62 avatar abdulwahaab710 avatar abhro avatar benasocj avatar bling avatar chrisbra avatar fanglingsu avatar freed-wu avatar h3xx avatar hgigas avatar idbrii avatar inkarkat avatar jasoncodes avatar jean avatar jeetsukumaran avatar joelostblom avatar johnrichardrinehart avatar jungle-boogie avatar lapingenieur avatar multimeric avatar norisio avatar nvllsvm avatar openjck avatar outtersg avatar pkrog avatar qrevel avatar ryanoasis avatar sheerun avatar sven-hergenhahn-dmtech avatar zhaocai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csv.vim's Issues

changing colorscheme makes syntax lose all colors

The colors are fine on the initial file load, but if I change the colorscheme all the syntax colors disappear- including highlights not set by the csv syntax.

This appears to only affect files which use a delimiter other than comma. I have confirmed this with files using tab and pipe delimiters.

I get an error on opening csv files.

This appears on opening a csv file. Using vim 7.4

Error detected while processing function <SNR>27_LoadFTPlugin:
line    2:
E474: Invalid argument: fcs=vert:
E488: Trailing characters: ,fold:-

Save dynamic filter results to separate file

Hello,

Is there a vim way or a method with this plugin to save dynamically filtered results to a separate file?

After filtering a file, I have just 1,115 records showing but many, many folds visible so I attempt to do :w file.csv, it writes the file and I do a wc -l to find out I just duplicated the original file with 116877 lines.

Command names

Hi,

One more gripe. Never in my life will I remember the names of the commands this plug-in provides. If they had a common prefix, e.g., :CSVNewDelimiter instead of :NewDelimiter, I could rely on tab completion/wildmenu to find the command I want. Thoughts?

Virtual replace mode columns conflicts with vim-R-plugin

With the vim-R-plugin installed, and when editing a csv file, using gR, entering in a value, and then pressing <CR> doesn't cause the cursor to move down one row in the same column.

I'm not sure what the etiquette is on such conflicts -- should I open an issue on vim-R-plugin too?

CSVAnalyze giving funky results

So I'm doing CSVAnalyze on 65,867 records and it works pretty fast but the results are quite strange. My numbers are dollar amounts and some don't have a decimal.

I don't know markdown well enough to make the table look decent so it's here:
https://github.com/jungle-boogie/photographs/blob/master/results

As you see, four of the 5 results have 0% and interestingly the 1% result appears 8 times in the file.

Here's the data I used:
https://github.com/jungle-boogie/photographs/blob/master/data

Are these results expected?

Thanks,
jb

ArrangeColumn increase column width every time.

If I open a small CSV file, and :%ArrangeColumn, then the columns are arranged, with whitespace equal to the minimum +1. If I repeat :%ArrangeColumn, then the same thing happens, and now there is at least 2 spaces at the start of every column. Every time this is repeated, one more column of whitespace is added.

The preferred behaviour for me would be that every column has at most one column of pure whitespace after a separator. So if a CSV is already arranged, :%ArrangeColumn should do nothing, and if somehow a column already has more than 1 space before each cell (e.g. if some text was edited), then all but one of those spaces should be removed.

set csv-delimiter man page

Hello,

When you open a file that csv.vim doesn't not recognize with a valid header, you're advised:
CSV: No delimiter found. See :h csv-delimiter to set it manually!; however, vim complains this help page does not exist.

4.1 of the manual csv.vim manual indicates to use this to set delimiter:
:let g:csv_delim=','

When attempting to set the less common ':' as the delimiter, there is no error message but csv.vim doesn't seem to respect this delimiter, and you can test this by typing some data separated by : and then using the dynamic filter to see filter doesn't work.

Unusual behavior of af / if text objects when not on start of column.

Usually, text objects select around the cursor (when it is not directly positioned at the start of the object). The af / if text object select the following column, though. I find this confusing, and don't see any benefit.

Also, when inside the last column, if and af will select the entire next line, which I find unintuitive. (Would have expected the first column of the next line, though as I argue here, would prefer to select the current column.)

Partially updated 0.14 release on vim.org scripts site

I just wanted to let you know that the automatic upload of the 0.14 release to the main vim scripts site seems to have missed a few changes (minor changes in the ftplugin and doc files) that are in the official release.

Also, the script version is still shown as 0.13 so you may have a bug in your automatic upload script or something else went wrong.

csv_autocmnd_arrange file size threshold

It would be cool if instead of a binary setting:

let g:csv_autocmd_arrange=1

one could specify a maximum file size beneath which the Arrange command will autoexecute.

columns width behaviours an others tests

Hi Christian,

here below I submit some screenshots to show some minor points/possible small issues:

column widths (collpase feature)

see:
default_width

ArrangeColumn do great job here!
Nevertheless a possible useful feature could be to have a width collapse to show the minimum-necessary spaces, in the screen above there are many spaces between a column and another, that's clear but minimize the number of columns in view. Maybe a "Collapse" flag (why not a optional paremeter of ArrangeColumn command?) could help to set in view the max number of columns avoiding much panning (in case of many columns)... it's just a feature
(BTW I tested Fixed columns feature but I had no success, myabe I didn't well understood behaviour).

To be fully clear, now is like that:

TITLE OF COLUMN 1 | LONG TITLE OF COLUMN 2 | ...
             1890 |                   alfa | ...
             1894 |                   beta | ...
             1890 |                  gamma | ...

visualization proposed as optional ("ArrangeColumn collapse"):

    MN 1 |   LUMN 2 | ...
    1890 |     alfa | ...
    1894 |     beta | ...
    1890 |    gamma | ...

Setting vim numbering

If I set numbering on a CVV file, : set nu I got this:

Inumbering

so the header become dis-aligned. Minor point. if I reset vim numbering, all back correct:

Inumbering

ArrangeColumn does not fix sometime

Here below I edited line 11381 changing a filed in column 3 with vi command cwgiorgioybr01 and I got this:

Ino_arrange

strangely neither ArrangeColumn or %ArrangeColumn correct visualization.

CSVTable

if I run: :CSVTable

it seem that Header is not keep inside:
Table

Searching

Searching inside an (highlihghted) column is a great feature!
I experienced sometime that is printed sort of vimscript in last vim line.
just a bit confusing at first glance, but it's real a minor point :-)

Search

Sorry for my "picky" notes, is just to reward your great work on csv.vim!

respect
giorgio

ArrangeColumns not arranging right

I might be misunderstanding how this works, but given the following file:

csv-before

%ArrangeColumn gives me this result:

csv-after

Shouldn't the column separators be lined up?

Display-only live column arrangement?

It would be nice to have a view mode that is like the results of :ArrangeColumns, but doesn't actually modify the file. That is, column widths are calculated, and then the separator is displayed as <sep><x spaces> where x is column width - column contents width. Ideally, column widths would be corrected whenever a cell was edited (not while in insert mode, but after).

I'm not sure how feasible this would be, given Vim's structure, nor how computationally intensive this would be, but it would be really nice for smallish CSVs anyway.

dynamic filter and count

Hello,

Thank you for creating the wonderful vim plugin!

I have a column dynamically filtered and I'd like to count all instances that are now present with the filter. How can I do this? Skipping to the end of the file shows the last line number and all the folds but not a correct count.

Thanks,
jungle

CSV Syntax:Invalid column pattern, using default pattern \%([^,]*,\|$\) Error Message

Hello:

I am using your plugin in conjunction with the MySQL Workbench on Mac OS X 10.7.
When I export my sql scripts from the MySQL Workbench I get the following error message: CSV Syntax:Invalid column pattern, using default pattern %([^,]*,|$)
but if I cat the contents of the file I see that there is commas as delimiters in the file. Is
there something that I am doing wrong.

Sincerely,

Jean-Marcel Belmont

Feature UnArrange or Compact command

I would find it nice to have to possibility to compact a CSV File after I Arraged it, so that the additional spaces will be removed around the delimiters?

Would this be possible to do?

better tsv support

The plugin on the wiki here:
http://vim.wikia.com/wiki/Working_with_CSV_files
has decent support for tsv. Can you integrate that?

Also, some of the user-specified settings should be scoped to the buffer. This plugin requires setting g:csv_delim to change the delimiter, but that will apply to all buffers, so I can't open a csv in one buffer and a tsv in another. It is better for the user to set b:csv_delim. See how the previously mentioned plugin does it.

`:InitCsv` overrides locally set `b:delimiter`

If I set b:delimiter for a file (and update b:col accordingly) to handle a custom delimiter for a file, and at any time that call :InitCsv, the b:delimiter value gets set again to the default or g:csv_delim.

There are situations when :InitCsv might need to be called to, e.g., update/change highlighting, but we want the b:delimiter preserved if it was manually changed.

Since b:delimiter is set automatically, and there is (I think) no way to tell if it was manually changed, I suggest a non-userspace variable (e.g, b:_delimiter) that is set to g:csv_delim automatically, but is only used if b:delimiter is not set. But maybe some other solution would be better.

Dealing with large CSVs

Hey Chris,

first of all thanks for crafting this awesome VIM plugin!

I tested you file with a more or less large CSV and tried the nifty :%ArrangeColumn on it - and it takes very long to finsh. Is there a trick maybe to deal with large CSVs? Something like partial or streamed loading of a file? Or a lazy evaluating application of commands?

I checked the help file (Ctrl-F) but couldn't find something helping me in that regard.

Kind regards

Raffael

Custom CSVColumnEven highlight does not work

the hi CSVColumnEven term=NONE ctermbg=NONE in my .vimrc seems to be overwritten when a csv file is loaded. It is set to my modified value when vim is started, but overwritten when I load a .csv file.

error at vim startup

how to avoid this error:

CSV Syntax:Invalid column pattern, using default pattern \%([^,]*,\|$\)

alignement issues and a thank you!

Hi Christian!

First of all I want to thank you for you great work here. Not a real issue indeed, here just few notes and some things that are not immediate to me (vim beginner):

1- Column Alignement
If open a CSV file and so I give command:

:%ArrangeColumn

I got colums field right-aligned.

Now, let say I want instead to left-align, I do command:

:let b:csv_arrange_leftalign = 1

I don't have any immediate effect

even if I run again %ArrangeColumn

strange. it seem to me that alignement do not run as a Toggle in runtime.
That could be instead an useful feature, I mean a command like
:Align {left|right}.

2- Colors
there is a way to change column colouring ?

3- Default behaviours
After installing your plugin (last release today), If I open somefile.csv, vim recognize the filetype .csv, header is colored red ann columns ar coloured green/blue without any alignement.
Ok, I configure my .vimrc to do some initializations, but maybe alignement with ArrangeColumns could be a defaulyt :-)

4-Despite your documentation is excellent withoout dubt, maybe a screencast on youtube or similar could help beginners :-) do you thinked about it ?

thanks again
giorgio

x,%Sort y

I would expect
:2,%Sort 1

To sort from line 2 to the end of the file on column 1, but it sorts the entire file.

:2,xSort 1 where x is the last line of the file does work.

Hat delimiter not working

When I set the delimiter to ^ in the vimrc:

let g:csv_delim="^"

The plugin does not seem to work on a file like this:

1^2^3
4^5^6

csv.vim is not finding rgb.txt valid colors

Not sure why this is erroring out on .vimrc, I do have $VIMRUNTIME defined as well.

E254: Cannot allocate color PaleTurquois

lines from rgb.txt

 70 130 180   SteelBlue
176 196 222   light steel blue
176 196 222   LightSteelBlue
173 216 230   light blue
173 216 230   LightBlue
176 224 230   powder blue
176 224 230   PowderBlue
175 238 238   pale turquoise
175 238 238   PaleTurquoise
  0 206 209   dark turquoise
  0 206 209   DarkTurquoise
 72 209 204   medium turquoise
 72 209 204   MediumTurquoise
 64 224 208   turquoise
  0 255 255   cyan
224 255 255   light cyan
224 255 255   LightCyan
 95 158 160   cadet blue
 95 158 160   CadetBlue
102 205 170   medium aquamarine
102 205 170   MediumAquamarine
127 255 212   aquamarine
  0 100   0   dark green
  0 100   0   DarkGreen
 85 107  47   dark olive green
 85 107  47   DarkOliveGreen
143 188 143   dark sea green
143 188 143   DarkSeaGreen
 46 139  87   sea green
 46 139  87   SeaGreen
 60 179 113   medium sea green
 60 179 113   MediumSeaGreen
 32 178 170   light sea green
 32 178 170   LightSeaGreen
152 251 152   pale green
152 251 152   PaleGreen

CSV::MalformedCSVError

Hi, i am able to import 1000s of records through CSV. I am having fields like email, name, address...
In csv file we will enter address as:
[email protected],Tom Cruise,"2-3-44, New York, USA"
If we miss closing quotes for address in some line number 25 as:

"2-3-44, New Delhi, India #without the close of quotation

I am getting the error as:

CSV::MalformedCSVError in Administration::CollegeController#import_csv
Illegal quoting in line 24.

I want an flash error message instead of the above error page.

Here is my controller code:

def import_csv
if params[:file].blank?
flash[:error] = "Select a CSV file to upload data."
redirect_to :back
elsif params[:file].original_filename.split('.').last != "csv"
flash[:error] = "Please upload valid csv file."
redirect_to :back
else
n = not_valid = 0
col2 = []
errors = ""
CSV.foreach(params[:file].tempfile) do |row|
if n == 0
n += 1
next
end
col1 = import_from_csv(row)
unless col1.valid?
not_valid += 1
col1.errors.full_messages.each{|m| errors << " At Line : #{n+1}
#{m}
" }
end
col2 << col1
n += 1
end
unless not_valid >= 1
col2.each(&:save)
redirect_to administration_college_users_path,:notice => "#{n-1} fields imported successfully"
else
@errors = "Errors:
#{errors}"
render :load_csv
end
end
end
private
def import_from_csv(row)
College.new( :contact_email => row[0],:name => row[1], :address=>row[2])
end

Please try to help me out..

ConvertData ignoring dynamic filters

Hello,

Is it the intention of the csv.vim plugin's CSVConvert option to ignore dynamically filtered data and convert an entire file when you only wanted a subsection?

My 12 MB file (116877 lines) turned into a 22MB html file after I wanted to convert only 6 rows and 8 columns.

Thanks!

Many Errors after changing the filetype

If I load a csv file and want to change the filetype to disable the csv features by setting :set ft=txt or somethin similar, I get many error on using h, j ,k , l and the cursor keys for movement that make it impossible to work unti the filetype is set back to csv.

Error for h, j, k and l keys are only shown if g:csv_highlight_column is enabled, because the HiColumn function isn't available anymore but already referenced throuhgt autocommand for CursorMoved.

Maybe we should have a second function to cleanup all staff done by InitCSV.

Make ConverData align decimal points

Hi,

Is it possible to use ConvertData to align decimal points?
I have a data file where the decimal points should be at a specific place.

I have tried to type something like this at the third question after ConvertData

%s %s %s %s %s

(the raw line above shows different amount of spaces in between, but it is apparently processed and eaten by markdown).
So as you can see I have five columns.

Cheers,
Daniel

Infinite loop when pressing H in the first row first column

When pressing H in the first column on any row except the first, the cursor wraps around to the last column of the previous row.

Pressing H in the first column of the first row, vim enters some sort of infinite loop, stops responding and must be killed.

This is Vim 7.4 on Linux. It happens both in console vim and gvim.

Does not reset original 'foldtext'

Hi,

This plug-in blows away my custom foldtext setting. I notice it gets set in ftplugin/csv.vim and then restores Vim's default value in b:undo_ftplugin.

I'm not even sure why csv.vim touches foldtext. I vote for removing it altogether.

Thanks for your consideration.

AddColumn inserts column before current column, instead of after

According to the documentation, AddColumn is supposed to add a column after the current column. It seems to insert column before the current column instead, except for the last column, where it adds column after the last column correctly. If I try to specify column using a numeric argument, using

:AddColumn 13

I get the following error:

Error detected while processing function <SNR>129_AddColumn:
line   27:
E121: Undefined variable: pos
line   30:
E121: Undefined variable: pos
E15: Invalid expression: pos == 0
line   38:
E121: Undefined variable: pat
E15: Invalid expression: pat != '$' || (pat == '$' &&  getline(a:stop)[-1:] == b:delimiter)
line   62:
E121: Undefined variable: pat
E116: Invalid arguments for function printf("sil %d,%ds/%s/%s/e", a:start, a:stop, pat, subst)
E15: Invalid expression: printf("sil %d,%ds/%s/%s/e", a:start, a:stop, pat, subst)

black/white columns make text unreadable

When I open a CSV file with csv.vim installed, it highlights the columns in alternating black and white. Since the text is also black, the black columns become unreadable. The columns are also not aligned. I am using the latest version of Vim (7.3) installed via Macports.

Prevents visualmode from selecting over multiple lines with arrow keys.

If csv.vim is enabled, I can't use v, <s-v> or <c-v> to select over multiple lines with the arrow keys. It still works with hjkl, but I don't really use these keys, so it is really annoying. Not sure if this is something to do with some other plugin or something.. Let me know if there is some more info I can provide.

:Sort problem

My :Sort is sorting by string length, not alpha or numeric. Am I doing something wrong? I just have my cursor in a column and I type the :Sort command....

Custom text group

A cool feature idea occurred to me today. It would be neat if one could vig ("visual-in-group") to visually select a contiguous block of rows, where a block is defined as all the contiguous rows having the same value in the cursor's column. Obviously this would only work for sorted data. Yank, delete, etc would be handy with this text group too. Does this sound possible?

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.