Coder Social home page Coder Social logo

csvaccess's Introduction

CSV Access

  • AlphaBooster 에서 CSV file 을 직접 읽어서 Array 저장 후 Lookup 하기 위한 VBA Code
  • CSVImport 에서 Sort 실행옵션을 주면 배열을 Quick Sort 로 정렬
  • 배열이 정렬되어있으면 Lookup / VLookup / VLookupAll 호출시에 Binary Search 로 검색 작업 자동 실행
  • 배열이 정렬되어있지않으면 순차검색

작동 프로세스 및 구조

CSV Access Process

  1. Sub CSVImport(CSVFileName, Array(), KeyCol, SortFlag)
  • CSV data file 의 내용을 Array() 배열에 저장. String 속성의 배열임
  • 1st 파라미터(CSVFileName) : 대상 CSV 파일명
  • 2nd 파라미터(Array()) : CSV 내용을 반환받기 위한 배열
  • 3rd 파라미터(KeyCol) : CSV 내용 중 Key Field 의 위치를 담고 있는 변수. 콤마로 구분
  • 4th 파라미터(SortFlag) : 배열의 Sorting 여부. 0 이면 정렬하지 않음. 1이면 정렬(QuickSort)
  1. Function VLookup(Key, Array(), j)
  • VLookup Function : 반환값은 반드시 Double type
  • 1st 파라미터(Key) : 찾고자 하는 Key 값
  • 2nd 파라미터(Array()) : Source Array 전체
  • 3rd 파라미터(j) : 값을 가지고 오는 대상 컬럼 순번
  1. Function VLookupAll(Key, Array())
  • VLookupAll Function - VLookup 과 유사하나 Key 에 해당하는 행 값 전체를 반환받음
  • 반환값은 반드시 String Type. comma 로 구분되어있기 때문에 반드시 Split 처리해줘야 함
  • 1st 파라미터(Key) : 찾고자 하는 Key 값
  • 2nd 파라미터(Array()) : Source Array 전체
  1. Function HLookupAll(FieldName, Array())
  • HLookupAll Function - VLookup 과 유사하나 TargetField 에 해당하는 열 값 전체를 반환받음
  • 반환값은 반드시 String Type. comma 로 구분되어있기 때문에 반드시 Split 처리해줘야 함
  • 1st 파라미터(FieldName) : 찾고자 하는 필드명
  • 2nd 파라미터(Array()) : Source Array 전체
  1. Function Lookup(Key, Array(), FieldName)
  • Lookup Function - VLookup 과 동일한 작동. 필드 번호 대신 필드명을 직접 입력
  • 1st 파라미터(Key) : 찾고자 하는 Key
  • 2nd 파라미터(Array()) : Source Array
  • 3rd 파라미터(FieldName) : 값을 가지고 오는 대상 컬럼 이름

UDF.BAS 의 sub 및 function 을 이용해서 CSV File Access 를 하는 Sample Code

주의사항

  1. 아래의 사항은 CSV 파일 내용에서 반드시 지켜져야 함
  • CSV 파일의 첫번째 줄은 Field 별 이름 (필수)
  • CSV 파일의 두번째 줄은 Field 별 Data type 정의 (필수)
  • CSV 파일의 세번째 줄은 Field 별 설명 (옵션)
  • CSV 파일의 네번째 줄부터 Data
  1. CSVImport Sub 사용시 주의 사항
  • CSV 파일 내용을 받아오는 Array 의 Index 는 반드시 0 부터 시작해야 함
  • Index 0 에 CSV 헤더 정보를 저장함
  • 기존에는 Index 10 까지 헤더정보 저장하였으나 배열 선언시 사이즈 지정에 혼동 및 오류을 초래할 가능성이 높아서 로직 수정

csvaccess's People

Contributors

hyunsikhwang avatar hokyeongyoo avatar

Watchers

James Cloos avatar

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.