'Programming/node.js'에 해당되는 글 142건

  1. 2019.11.06 node.js synchornous file write
  2. 2019.09.24 postgres on node.js
  3. 2019.09.18 json2csv / node.js 에서 NULL 값 출력하기
  4. 2019.09.15 js nested function과 변수 scope
  5. 2019.09.10 node.js util.format / sprintf?
  6. 2019.09.10 node.js xpath 지원함수 목록
  7. 2019.08.21 node.js csv2json
  8. 2019.08.12 node.js regex
  9. 2019.08.08 node.js xpath 모듈
  10. 2019.08.07 xpath text()
Programming/node.js2019. 11. 6. 20:19

파일이 이상하게 저장되는 것 같아서 찾아보는데

결론만 말하자면.. 순차적으로 쓰는게 아니라 하나의 스트림을 여러군데에서 쓰면 문제의 소지가 있으니

synchronous로 쓰라인데.. 스트림 아웃이면 라인 단위로 되려나 어떻게 처리하게 되려나?

이런 부분을 좀 명확하게 찾아 봐야 할 듯.

 

[링크 : https://www.daveeddy.com/2013/03/26/synchronous-file-io-in-nodejs/]

[링크 : https://stackoverflow.com/...-write-to-append-to-the-same-file-guarantee-the-order-of-executio]

'Programming > node.js' 카테고리의 다른 글

node.js xpath 그리고 boolean  (0) 2019.12.17
node.js JWT with refresh token  (0) 2019.12.10
postgres on node.js  (0) 2019.09.24
json2csv / node.js 에서 NULL 값 출력하기  (0) 2019.09.18
js nested function과 변수 scope  (0) 2019.09.15
Posted by 구차니
Programming/node.js2019. 9. 24. 17:53

테스트용 was나 하나 짜볼까나...

 

[링크 : https://araikuma.tistory.com/459]

 

+ 2019.12.10

[링크 : https://node-postgres.com/]

'Programming > node.js' 카테고리의 다른 글

node.js JWT with refresh token  (0) 2019.12.10
node.js synchornous file write  (0) 2019.11.06
json2csv / node.js 에서 NULL 값 출력하기  (0) 2019.09.18
js nested function과 변수 scope  (0) 2019.09.15
node.js util.format / sprintf?  (0) 2019.09.10
Posted by 구차니
Programming/node.js2019. 9. 18. 19:29

value = undefined; 로 하면

csv 출력시 ,, 로 NULL 값으로 인식되도록 출력된다.

 

[링크 : https://www.npmjs.com/package/json2csv]

'Programming > node.js' 카테고리의 다른 글

node.js synchornous file write  (0) 2019.11.06
postgres on node.js  (0) 2019.09.24
js nested function과 변수 scope  (0) 2019.09.15
node.js util.format / sprintf?  (0) 2019.09.10
node.js xpath 지원함수 목록  (0) 2019.09.10
Posted by 구차니
Programming/node.js2019. 9. 15. 18:30

함수 내부의 함수는

내부 함수가 포함된 영역의 변수까진 유효하게 건드릴수 있는 듯 하다.

[링크 : https://www.w3schools.com/js/js_function_closures.asp]

'Programming > node.js' 카테고리의 다른 글

postgres on node.js  (0) 2019.09.24
json2csv / node.js 에서 NULL 값 출력하기  (0) 2019.09.18
node.js util.format / sprintf?  (0) 2019.09.10
node.js xpath 지원함수 목록  (0) 2019.09.10
node.js csv2json  (0) 2019.08.21
Posted by 구차니
Programming/node.js2019. 9. 10. 12:45

sprintf() 처럼 %d로 치환해서 출력가능한 모듈이 util.format()으로 존재한다.

 

[링크 : https://nodejs.org/api/util.html#util_util_format_format_args]

'Programming > node.js' 카테고리의 다른 글

json2csv / node.js 에서 NULL 값 출력하기  (0) 2019.09.18
js nested function과 변수 scope  (0) 2019.09.15
node.js xpath 지원함수 목록  (0) 2019.09.10
node.js csv2json  (0) 2019.08.21
node.js regex  (0) 2019.08.12
Posted by 구차니
Programming/node.js2019. 9. 10. 10:24

count()가 잘 안되서 지원이 안되는건줄 알았는데 엉뚱한 경로를 해놓고 헤매고 있었다..

FunctionResolver.prototype.addStandardFunctions = function() {
this.functions["{}last"] = Functions.last;
this.functions["{}position"] = Functions.position;
this.functions["{}count"] = Functions.count;
this.functions["{}id"] = Functions.id;
this.functions["{}local-name"] = Functions.localName;
this.functions["{}namespace-uri"] = Functions.namespaceURI;
this.functions["{}name"] = Functions.name;
this.functions["{}string"] = Functions.string;
this.functions["{}concat"] = Functions.concat;
this.functions["{}starts-with"] = Functions.startsWith;
this.functions["{}contains"] = Functions.contains;
this.functions["{}substring-before"] = Functions.substringBefore;
this.functions["{}substring-after"] = Functions.substringAfter;
this.functions["{}substring"] = Functions.substring;
this.functions["{}string-length"] = Functions.stringLength;
this.functions["{}normalize-space"] = Functions.normalizeSpace;
this.functions["{}translate"] = Functions.translate;
this.functions["{}boolean"] = Functions.boolean_;
this.functions["{}not"] = Functions.not;
this.functions["{}true"] = Functions.true_;
this.functions["{}false"] = Functions.false_;
this.functions["{}lang"] = Functions.lang;
this.functions["{}number"] = Functions.number;
this.functions["{}sum"] = Functions.sum;
this.functions["{}floor"] = Functions.floor;
this.functions["{}ceiling"] = Functions.ceiling;
this.functions["{}round"] = Functions.round;
};

[링크 : https://github.com/goto100/xpath/blob/master/xpath.js]

'Programming > node.js' 카테고리의 다른 글

js nested function과 변수 scope  (0) 2019.09.15
node.js util.format / sprintf?  (0) 2019.09.10
node.js csv2json  (0) 2019.08.21
node.js regex  (0) 2019.08.12
node.js xpath 모듈  (0) 2019.08.08
Posted by 구차니
Programming/node.js2019. 8. 21. 18:23

csv 파일을 받아서(파일명으로만) 읽어온 뒤 array로 만들어 주는 참한 녀석

(스트림으로 읽는진 모르겠어서 대용량 처리 가능한진 모르겠다)

 

const csvFilePath = 'test.csv'
const csv = require('csvtojson')
csv()
    .fromFile(csvFilePath)
    .then((jsonObj) => {
        jsonObj.forEach(ele => {
            // console.log(ele.idx)
            // console.log(ele.disease_name)
            // console.log(ele.doid)
            // console.log(ele.refsite)
            // console.log(ele.ref_id)

            var dis = ele.disease_name.split(';')
            var ret = "";
            // console.log(dis)
            // console.log(dis.length)
            if(dis.length > 1)
            {
                dis.forEach(ele2 => {
                    ret = '"' + ele.idx + '"';
                    ret += ","
                    ret += '"' + ele2 + '"';
                    ret += ","
                    ret += '"' + ele.doid + '"';
                    ret += ","
                    ret += '"' + ele.refsite + '"';
                    ret += ","
                    ret += '"' + ele.ref_id + '"';
                    console.log(ret)
                })
            }
            else{
                ret = '"' + ele.idx + '"';
                ret += ","
                ret += '"' + ele.disease_name + '"';
                ret += ","
                ret += '"' + ele.doid + '"';
                ret += ","
                ret += '"' + ele.refsite + '"';
                ret += ","
                ret += '"' + ele.ref_id + '"';
                console.log(ret)
            }
            
        })

    })

[링크 : https://www.npmjs.com/package/csvtojson]

'Programming > node.js' 카테고리의 다른 글

node.js util.format / sprintf?  (0) 2019.09.10
node.js xpath 지원함수 목록  (0) 2019.09.10
node.js regex  (0) 2019.08.12
node.js xpath 모듈  (0) 2019.08.08
xpath text()  (0) 2019.08.07
Posted by 구차니
Programming/node.js2019. 8. 12. 16:57

별다른 모듈 끌어오지 않아도 기본으로

new RegExp()를 통해 생성이 가능하다.

 

아래는 파일명에서 YYYY-MM 으로 된 녀석을 검색하는 예제

음.. 근데 딱 그 부분만 빼내는 법은 없나?

> var regex =  new RegExp('[0-9]{4}-[0-9]{2}')
undefined
> regex
/[0-9]{4}-[0-9]{2}/
> var fn = "ClinVarFullRelease_2019-07.xml"
undefined
> fn.match(regex);
[ '2019-07', index: 19, input: 'ClinVarFullRelease_2019-07.xml' ]

[링크 : https://stackoverflow.com/questions/5675315/node-js-regular-expression-to-get-from-and-to]

 

+

regex.exec(fn)

[링크 : https://opentutorials.org/course/50/43]

 

+

()로 묶으면 완전히 매칭되는 부분만 결과를 돌려준다.

> var regex =  new RegExp('([0-9]{4}-[0-9]{2})')
undefined
> fn.match(regex);
[ '2019-07',
  '2019-07',
  index: 19,
  input: 'ClinVarFullRelease_2019-07.xml' ]

[링크 : https://bradbury.tistory.com/47]

'Programming > node.js' 카테고리의 다른 글

node.js xpath 지원함수 목록  (0) 2019.09.10
node.js csv2json  (0) 2019.08.21
node.js xpath 모듈  (0) 2019.08.08
xpath text()  (0) 2019.08.07
node.js readline과 r/w stream  (0) 2019.07.31
Posted by 구차니
Programming/node.js2019. 8. 8. 11:04

이것저것 테스트 하다가 가장 무난한게 select1 인것 같고

검색이 되지 않으면 탭이나 콤마를

검색이 되었으나 값의 저장위치에 따라 value와 firstChild.data로 저장이 된다.

firstChild.data는 element 자체의 내용(content라고 해야하나 머라고 해야하나?)이 저장되는 장소이다.

 

var result_attr = xpath.select1(ele, doc);
                    // var result_ele = xpath.select(ele, doc);

                    if (result_attr != undefined) {
                        if (result_attr.value != undefined) {
                            // record += (result_attr.firstChild + delimiter)
                            record += ('"' + result_attr.value + '"' + delimiter)
                            // console.log(result_attr.value);
                        }
                        else {
                            record += ('"' + result_attr.firstChild.data + '"' + delimiter)
                            // console.log(result_attr.firstChild.data);
                        }
                    }
                    else {
                        record += delimiter;
                    }

 

 

 

'Programming > node.js' 카테고리의 다른 글

node.js csv2json  (0) 2019.08.21
node.js regex  (0) 2019.08.12
xpath text()  (0) 2019.08.07
node.js readline과 r/w stream  (0) 2019.07.31
node.js xpath select() select1()  (0) 2019.07.25
Posted by 구차니
Programming/node.js2019. 8. 7. 23:15

<element>text</element>

에서 text만 꺼내주는 함수(?)

'Programming > node.js' 카테고리의 다른 글

node.js regex  (0) 2019.08.12
node.js xpath 모듈  (0) 2019.08.08
node.js readline과 r/w stream  (0) 2019.07.31
node.js xpath select() select1()  (0) 2019.07.25
node.js xpath apidoc  (0) 2019.07.25
Posted by 구차니