Git Product home page Git Product logo

pgtab's Introduction

๐Ÿ‘‹ Hi

๐Ÿ’ป I'm a longtime Mac user (macOS=unix) and command line aficiando.

๐Ÿ˜ฎ I started programming with an Apple ][e in the early 1980s.

๐Ÿ”ง I wrangle data with basic Unix commands, shell scripts, PostgreSQL, Python, and other open source software.

โœ๏ธ I use git and GitHub Pages to keep and share notes about the software I use.

โค๏ธ I enjoy writing about technology and inevitably learn a lot in the process.

โ˜•๏ธ You're not really interested in my hobbies or personal life, are you?

๐Ÿ”– "So it goes."

โ€” PostgreSqlStan

pgtab's People

Contributors

postgresqlstan avatar

Stargazers

 avatar

Watchers

 avatar

pgtab's Issues

the self-concatenating table is entertaining but a bad idea; will remove eventually

pgtab/sql/02_import.sql

Lines 18 to 42 in 95066ea

CREATE FUNCTION tf_fix_multiline_json()
RETURNS TRIGGER AS $TF$
-- โš ๏ธ probably bad idea, but had to try it
-- will likely remove (soon) and perform in procedure instead
-- conditionally remove linefeeds from multiline json
DECLARE
is_json_rows BOOL;
BEGIN
IF ((SELECT COUNT(*) FROM i_text LIMIT 2) > 1) THEN
WITH a AS (SELECT distinct(left(t,1) || right(t,1)) AS da
FROM i_text LIMIT 5)
SELECT (SELECT count(*) FROM a)=1 AND (SELECT TRUE FROM a WHERE da='{}')
INTO is_json_rows;
-- don't concatenate to single row if it's rows of valid JSON
IF NOT is_json_rows THEN
CREATE TEMPORARY TABLE fix(t TEXT);
INSERT INTO fix SELECT string_agg(t, ' ') FROM i_text;
DELETE FROM i_text;
INSERT INTO i_text SELECT * FROM fix;
DROP TABLE fix;
END IF;
END IF;
RETURN NEW;
END;
$TF$ LANGUAGE plpgsql;

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.