2014-02-23 4 views
1

그래서 데이터를 추출하고 새 txt 파일에 쓸 파일 세트가 있는데 파이썬으로이 작업을 수행하는 방법을 모르겠습니다. 다음은 샘플 데이터입니다. NSF 조직, 파일 및 초록에서 부품을 추출하려고합니다.텍스트 파일에서 데이터를 추출하는 방법은 무엇입니까?

제목 : CRB : 미토콘드리아 DNA와 역사 인구 유형 : Mysticete 고래의 멸종 위기에 처한 집단의 유전 적 다양성 상 NSF 조직 : DEB 최신 개정 날짜 : 1991년 8월 1일
파일 : a9000006

상 번호 : 9000006 상 측량기 : 계속 부여
PRGM 관리자 : 환경 생물의 스콧 콜린스
DEB DIVISION BIO 직접, 생명 과학
시작 날짜 : 6 월 1 일
1990 년 만료 11 월 (30), 1992 예상 총 AMT 사의 (예상). : $ 17만9천7백20 (예상) 탐정 : 스티븐 R. Palumbi (연구 책임자 전류) 스폰서 : 하와이 마노아 2530 돌 거리 호놀룰루의 U, HI 968,222,225 808/956-7800

NSF 프로그램 : 1127 체계적인 & 인구 BIOLO 타코마 Applictn : 0,000,099 기타 응용 프로그램 NEC
(61) 생명 과학 생물
프로그램 참조 : 9285, 추상 :

  Commercial exploitation over the past two hundred years drove the great  
      Mysticete whales to near extinction. Variation in the sizes of populations 
      prior to exploitation, minimalpopulation size during exploitation and 
      current population sizes permit analyses of the effects of differing levels 
      of exploitation on species with different biogeographical distributions and 
      life-history characteristics. 

답변

0

당신은 나에게 많은 것을주지 않고 있지만 txt 파일에서 입력 파일을 읽으려면 어떻게해야합니까? 이 잘하면 당신이

#!/bin/env python2.7 

# Change this to the file with the time input 
filename = "filetext" 

storeData = [] 

class Whatever: 
def __init__(self, time_str): 
    times_list = time_str.split('however you want input to be read') 
    self.a = int(times_list[0]) 
    self.b = int(times_list[1]) 
    self.c = int(times_list[2]) 
    # prints the data 
    def __str__(self): 
    return str(self.a) + " " + str(self.b) + " " + str(self.c) 
+0

당신이 파이썬 코드를하시기 바랍니다 제안 할 수 있습니다 어떤 종류의

import java.util.Scanner; import java.io.*; public class ClockAngles{ public static void main (String [] args) throws IOException { Scanner reader = null; String input = ""; try { reader = new Scanner (new BufferedReader (new FileReader("FilePath"))); while (reader.hasNext()) { input = reader.next(); System.out.print(input); } } finally { if (reader != null) { reader.close(); } } 

파이썬 코드의 배열에 저장하는 방법을 알고 있습니다, 자바로 무엇입니까? –

+0

답장을 보내 주셔서 감사합니다. 나는 꽤 새로운데,이 코드를 알아 내려고 노력했지만 time_list [] 라인에 대해 혼란 스럽다. 설명해 주시겠습니까? 정말 고마워. –

+0

글쎄, 이건 txt 파일에서 시간을 읽는 내 코드 였어. time_list는 배열입니다. – KRUKUSA

관련 문제