Cell character limit

good evening
I have a problem, I’m basically working on a csv file and I need to limit the number of characters in a cell (80 characters)

I have tried several methods but I don’t find anything effective, practically I would need that when I reach 80 characters I block the insertion of new characters

I have to make titles for ebay which has a limitation of 80 characters but I don’t know how to do it

Thanks for your help

Stephen

csv is a database exchange format. It has nothing to do with spreadsheets no matter how many users load csv into sheets.

Every database column with text content can be set up with a length limit.

No, you can not load text files into the LibreOffice Base component. Things are more complicated and more powerful. Everything depends on the exact details of concrete text data.

ok, and how do i set this text limit? thanks

Same question at Italian category: Limite caratteri cella.
Follow discussion here. Thanks.

Are we tallking about “turbo lister csv” described here: eBay: seller tools: turbo lister: csv ?

no no, I probably don’t explain myself well … I just need to find a way to not enter more than 80 characters in the cell of this csv, that’s all

https://help.libreoffice.org/7.3/en-US/text/scalc/01/12120100.html?System=UNIX&DbPAR=CALC&HID=modules/scalc/ui/validationcriteriapage/ValidationCriteriaPage#bm_id3145673

The use of Data Validation is what the solution below is based on. Unfortunately, if used directly Data Validation will just wipe out the entry in the cell rather than truncating it or, say, beeping and stopping at the entry limit. The example ODS in the solution tries to mitigate that.

This is one of the 99 reasons why I would make a csv editor in Base. However, this is impossible without knowing anything about the data to be processed.

1 Like

I tried but it makes me continue writing even after 80 characters and it does not block me before, only when I press enter it gives me an error, instead I would like it to stop me writing

The text box of an input form can be set up with a max. text length and behaves like this.

Download and extract the TextDB.zip
Open CSV_Editor.odb
Open the input form.
This example DB does not include any text field with limited lenght but what you ediit in the form is the linked Table1.csv in the same directory.

t75885.odt (9.6 KB)

This isn’t a perfect solution, but I think it is a reasonable enough compromise. Here we use Data Validation coupled with an OnChange event for the sheet. Then, since obviously all this cannot be in a CSV file, we have an export option to CSV so that the original file is always kept as an ODS. The macro also models selecting sheets by some part of the sheet name. This can easily just be removed if not needed.

Really, it could all be done in OnChange, I suspect, but this seems tidy enough. Notice that the Truncate() macro has to be assigned under Data Validity. That assignment will, though, get copied to another cell along with the rest of the Data Validity just by doing format painting from a cell that is already setup.

Naturally, instead of having a push button for export that might cover some of your cell entries, you would launch the export macro by customizing your Toolbar or assigning it to a keystroke.

CharacterLimitCSV.ods (15.6 KB)

[Edit: Remove a line of zombie code, etc.]