Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 87055

Re: Re: Find the row contents in CSV File

$
0
0

Hi,

 

locate proper index in 1st line ==> go down to proper line ==> grab proper value using index

 

Like below:

var  csvFile = File("~/Desktop/Book1.csv");  columnHead = "fg",  rowHead = "found",  mResult = findRowColValue(csvFile, columnHead, rowHead);

function findRowColValue(csvFile, X_value, Y_value) {
  // return value from cell found by crossing X_value (column) and Y_value (row)  // if wrong X/Y values ==> return false  var  cLine, cLineArr, xIdx;  csvFile.open("r");  cLine = "," + csvFile.readln();  xIdx = (cLine).search("," + String(X_value) );  if (xIdx !=-1) xIdx = cLine.slice(0, xIdx).split(",").length - 1;  else return false;  // start to read a file from 0 point  csvFile.open("r");  do {  cLineArr = csvFile.readln().split(",");  if (cLineArr[0] == Y_value) {     csvFile.close();     return cLineArr[xIdx];     }  }  while ( !csvFile.eof )  csvFile.close();  return false;  }

 

Jarek


Viewing all articles
Browse latest Browse all 87055

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>