Sujet : Re: Attention All Gentoo Men!
De : nospam (at) *nospam* dfs.com (DFS)
Groupes : comp.os.linux.advocacyDate : 28. Apr 2024, 19:47:48
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v0m244$164ic$2@dont-email.me>
References : 1 2 3 4 5
User-Agent : Betterbird (Windows)
On 4/28/2024 10:13 AM, Tyrone wrote:
On Apr 27, 2024 at 3:25:50 PM EDT, "Stéphane CARPENTIER" <sc@fiat-linux.fr>
wrote:
But YOU are not a programmer
>
Neither are you. And it doesn't require a great deal of knowledge to
know more than you about programming.
Anyone who has written a Tic-Tac-Toe program knows more about programming than
Farley Fucktard/Diego Dipshit/whatever name he is calling himself today.
Remember, he is the doofus who proclaims that "All programming is math" (It
will certainly look that way if the only "programming" you do is to solve
trivial math problems which BTW have already been solved), that a .csv file is
a "database" (Um, no. You import the .csv file INTO a database)
Feeb often expands or contracts the meaning of a word or idea to support what he's arguing that day.
On day 1 a .csv file IS a database.
On day 2 a .csv file IS NOT a database.
On day 1 there is no such thing as a text file.
On day 2 there is such a thing as a text file.
On day 1 AutoCAD is 'fantastic'.
On day 2 AutoCAD is 'overblown junk'.
On day 1 'software never expires'.
On day 2 'whine whine whine that DFS is using Office 2003'
That's how the confused fraud works.
and that one needs to "write a computer program" to determine the
field widths in a .csv file (clueless kiddie, learn some SQL).
You don't need to, but you can.
https://imgur.com/a/pLqp6SoWriting that C program was exponentially more difficult than importing .csv files into a dbms and using SQL. But now it runs instantaneously with almost no work on my part.
Anyway, I just now figured out something cool in SQLite:
Run this query (replace tblname with the actual table name)
SELECT "SELECT '" || name || "' AS Column, MAX(LENGTH(" || name || ")) AS MAXLEN FROM tblname UNION ALL " FROM PRAGMA_TABLE_INFO('tblname');
It will return a row for each column in the table.
Paste all the results into a SQL editor window, delete the final 'UNION ALL', terminate the SQL and run it and you get the max width of the data in each column. I did it for a table named 'XOVER'.
SELECT 'SERVERID' AS Column, MAX(LENGTH(SERVERID)) AS MAXLEN FROM XOVER UNION ALL
SELECT 'GROUPID' AS Column, MAX(LENGTH(GROUPID)) AS MAXLEN FROM XOVER UNION ALL
SELECT 'NEWARTICLEID' AS Column, MAX(LENGTH(NEWARTICLEID)) AS MAXLEN FROM XOVER UNION ALL
SELECT 'MESSAGEID' AS Column, MAX(LENGTH(MESSAGEID)) AS MAXLEN FROM XOVER UNION ALL
SELECT 'XOVER' AS Column, MAX(LENGTH(XOVER)) AS MAXLEN FROM XOVER UNION ALL
SELECT 'POSTER' AS Column, MAX(LENGTH(POSTER)) AS MAXLEN FROM XOVER UNION ALL
SELECT 'SUBJECT' AS Column, MAX(LENGTH(SUBJECT)) AS MAXLEN FROM XOVER UNION ALL
SELECT 'UTCDATETIME' AS Column, MAX(LENGTH(UTCDATETIME)) AS MAXLEN FROM XOVER;
results
SERVERID 1
GROUPID 2
NEWARTICLEID 7
MESSAGEID 212
XOVER 3536
POSTER 208
SUBJECT 1250
UTCDATETIME 19
sweet! That will definitely come in handy sometime.
Note: 'UNION ALL' maintains the order of the columns in the schema, while 'UNION' outputs them in alpha order.
This will go in my book:
'Tips, Tricks, Traps, Travails and Techniques for SQLite'.
I'm sure you can do similar or better in Oracle/SQLServer/Postgres/MariaDB with SQL.
https://stackoverflow.com/questions/20463365/looping-through-column-names-with-dynamic-sql