首页 > 解决方案 > 在 Java 中打开大型数据集和实例化数据的问题

问题描述

我正在尝试从 Java 中的 GIS 数据文本文件中读取,实例化每一行数据,然后对其进行排序、搜索和插入数据。我不断收到问题说“在 java.util.Scanner.next(未知来源)”并且无法解决这个问题。我还想知道是否有针对不同方法的建议。

我尝试使用数据类,在其中设置了我需要访问的所有变量,创建了 getter 和 setter 以及覆盖。然后我创建了一个新的数据数组,并if(input.hasNext())在其中设置了每个变量,然后创建了一个新的 GISData 实例。

public class GISRunner {

    /**
     * @param args
     */
    public static void main(String[] args) throws FileNotFoundException {
        File file = new File("C:\\Users\\Toby\\Desktop\\GIS.txt");
        Scanner input = new Scanner(file);
        input.useDelimiter("||\n");

        GISData[] datas = new GISData[0];
        if(input.hasNext()) {
            int featureId = input.nextInt();
            String featureName = input.next();
            String featureClass = input.next();
            String stateCode = input.next();
            int stateId = input.nextInt();
            String countyName = input.next();
            int countyId = input.nextInt();
            String primaryLatitudeDMS = input.next();
            String primaryLongitudeDMS = input.next();
            double primaryLatitudeDecimal = Double.valueOf(input.next().substring(1));
            double primaryLongitudeDecimal = Double.valueOf(input.next().substring(1));
            String sourceLatitudeDMS = input.next();
            String sourceLongitudeDMS = input.next();
            double sourceLatitudeDecimal = Double.valueOf(input.next().substring(1));
            double sourceLongitudeDecimal = Double.valueOf(input.next().substring(1));
            int elevationMeters = input.nextInt();
            int elevationFeet = input.nextInt();
            String mapName = input.next();

            GISData newGISData = new GISData(featureId, featureName, featureClass, stateCode,
                    stateId, countyName, countyId, primaryLatitudeDMS, primaryLongitudeDMS, 
                    primaryLatitudeDecimal, primaryLongitudeDecimal, sourceLatitudeDMS, 
                    sourceLongitudeDMS, sourceLatitudeDecimal, sourceLongitudeDecimal, elevationMeters, 
                    elevationFeet, mapName);
            datas = addGISData(datas, newGISData);
        }
        for (GISData data : datas) {
            System.out.println(data);
        }
    }

    public static GISData[] addGISData(GISData[] datas, GISData dataToAdd) {
        GISData[] newGISData = new GISData[datas.length + 1 ];
        System.arraycopy(datas, 0, newGISData, 0, datas.length);
        newGISData[newGISData.length - 1 ] = dataToAdd;

        return newGISData;
    }

}


public class GISData implements Comparable<GISData> {
    public static enum SortByType {CountyName,
                                    FeatureName,
                                    PrimaryLatitude,
                                    PrimaryLongitude,
                                    SourceLatitude,
                                    SourceLongitude,
                                    ElevationFeet};

    private int featureId;
    private String featureName;
    private String featureClass;
    private String stateCode;
    private int stateId;
    private String countyName;
    private int countyId;
    private String primaryLatitudeDMS;
    private String primaryLongitudeDMS;
    private double primaryLatitudeDecimal;
    private double primaryLongitudeDecimal;
    private String sourceLatitudeDMS;
    private String sourceLongitudeDMS;
    private double sourceLatitudeDecimal;
    private double sourceLongitudeDecimal;
    private int elevationMeters;
    private int elevationFeet;
    private String mapName;
    private Date createdDate;
    private Date modifiedDate;
    private SortByType[] sortBy;


    public GISData(int featureId2, String featureName2, String featureClass2, String stateCode2, int stateId2,
            String countyName2, int countyId2, String primaryLatitudeDMS2, String primaryLongitudeDMS2,
            double primaryLatitudeDecimal2, double primaryLongitudeDecimal2, String sourceLatitudeDMS2, String sourceLongitudeDMS2, double sourceLatitudeDecimal2,
            double sourceLongitudeDecimal2, int elevationMeters2, int elevationFeet2, String mapName2) {
        featureId = featureId2;
        featureName2 = featureName;
        featureClass2 = featureClass;
        stateCode2 = stateCode;
        stateId2 = stateId;
        countyName2 = countyName;
        countyId2 = countyId;
        primaryLatitudeDMS2 = primaryLatitudeDMS;
        primaryLongitudeDMS2 = primaryLongitudeDMS;
        primaryLatitudeDecimal2 = primaryLatitudeDecimal;
        primaryLongitudeDecimal2 = primaryLongitudeDecimal;
        sourceLatitudeDMS2 = sourceLatitudeDMS;
        sourceLongitudeDMS2 = sourceLongitudeDMS;
        sourceLatitudeDecimal2 = sourceLatitudeDecimal;
        sourceLongitudeDecimal2 = sourceLongitudeDecimal;
        elevationMeters2 = elevationMeters;
        elevationFeet2 = elevationFeet;
        mapName2 = mapName;
    }
    /**
     * @return the featureId
     */
    public int getFeatureId() {
        return featureId;
    }
    /**
     * @param featureId the featureId to set
     */
    public void setFeatureId(int featureId) {
        this.featureId = featureId;
    }
    /**
     * @return the featureName
     */
    public String getFeatureName() {
        return featureName;
    }
    /**
     * @param featureName the featureName to set
     */
    public void setFeatureName(String featureName) {
        this.featureName = featureName;
    }
    /**
     * @return the featureClass
     */
    public String getFeatureClass() {
        return featureClass;
    }
    /**
     * @param featureClass the featureClass to set
     */
    public void setFeatureClass(String featureClass) {
        this.featureClass = featureClass;
    }
    /**
     * @return the stateCode
     */
    public String getStateCode() {
        return stateCode;
    }
    /**
     * @param stateCode the stateCode to set
     */
    public void setStateCode(String stateCode) {
        this.stateCode = stateCode;
    }
    /**
     * @return the stateId
     */
    public int getStateId() {
        return stateId;
    }
    /**
     * @param stateId the stateId to set
     */
    public void setStateId(int stateId) {
        this.stateId = stateId;
    }
    /**
     * @return the countyName
     */
    public String getCountyName() {
        return countyName;
    }
    /**
     * @param countyName the countyName to set
     */
    public void setCountyName(String countyName) {
        this.countyName = countyName;
    }
    /**
     * @return the countyId
     */
    public int getCountyId() {
        return countyId;
    }
    /**
     * @param countyId the countyId to set
     */
    public void setCountyId(int countyId) {
        this.countyId = countyId;
    }
    /**
     * @return the primaryLatitudeDMS
     */
    public String getPrimaryLatitudeDMS() {
        return primaryLatitudeDMS;
    }
    /**
     * @param primaryLatitudeDMS the primaryLatitudeDMS to set
     */
    public void setPrimaryLatitudeDMS(String primaryLatitudeDMS) {
        this.primaryLatitudeDMS = primaryLatitudeDMS;
    }
    /**
     * @return the primaryLongitudeDMS
     */
    public String getPrimaryLongitudeDMS() {
        return primaryLongitudeDMS;
    }
    /**
     * @param primaryLongitudeDMS the primaryLongitudeDMS to set
     */
    public void setPrimaryLongitudeDMS(String primaryLongitudeDMS) {
        this.primaryLongitudeDMS = primaryLongitudeDMS;
    }
    /**
     * @return the primaryLatitudeDecimal
     */
    public double getPrimaryLatitudeDecimal() {
        return primaryLatitudeDecimal;
    }
    /**
     * @param primaryLatitudeDecimal the primaryLatitudeDecimal to set
     */
    public void setPrimaryLatitudeDecimal(double primaryLatitudeDecimal) {
        this.primaryLatitudeDecimal = primaryLatitudeDecimal;
    }
    /**
     * @return the primaryLongitudeDecimal
     */
    public double getPrimaryLongitudeDecimal() {
        return primaryLongitudeDecimal;
    }
    /**
     * @param primaryLongitudeDecimal the primaryLongitudeDecimal to set
     */
    public void setPrimaryLongitudeDecimal(double primaryLongitudeDecimal) {
        this.primaryLongitudeDecimal = primaryLongitudeDecimal;
    }
    /**
     * @return the sourceLatitudeDMS
     */
    public String getSourceLatitudeDMS() {
        return sourceLatitudeDMS;
    }
    /**
     * @param sourceLatitudeDMS the sourceLatitudeDMS to set
     */
    public void setSourceLatitudeDMS(String sourceLatitudeDMS) {
        this.sourceLatitudeDMS = sourceLatitudeDMS;
    }
    /**
     * @return the sourceLongitudeDMS
     */
    public String getSourceLongitudeDMS() {
        return sourceLongitudeDMS;
    }
    /**
     * @param sourceLongitudeDMS the sourceLongitudeDMS to set
     */
    public void setSourceLongitudeDMS(String sourceLongitudeDMS) {
        this.sourceLongitudeDMS = sourceLongitudeDMS;
    }
    /**
     * @return the sourceLatitudeDecimal
     */
    public double getSourceLatitudeDecimal() {
        return sourceLatitudeDecimal;
    }
    /**
     * @param sourceLatitudeDecimal the sourceLatitudeDecimal to set
     */
    public void setSourceLatitudeDecimal(double sourceLatitudeDecimal) {
        this.sourceLatitudeDecimal = sourceLatitudeDecimal;
    }
    /**
     * @return the sourceLongitudeDecimal
     */
    public double getSourceLongitudeDecimal() {
        return sourceLongitudeDecimal;
    }
    /**
     * @param sourceLongitudeDecimal the sourceLongitudeDecimal to set
     */
    public void setSourceLongitudeDecimal(double sourceLongitudeDecimal) {
        this.sourceLongitudeDecimal = sourceLongitudeDecimal;
    }
    /**
     * @return the elevationMeters
     */
    public int getElevationMeters() {
        return elevationMeters;
    }
    /**
     * @param elevationMeters the elevationMeters to set
     */
    public void setElevationMeters(int elevationMeters) {
        this.elevationMeters = elevationMeters;
    }
    /**
     * @return the elevationFeet
     */
    public int getElevationFeet() {
        return elevationFeet;
    }
    /**
     * @param elevationFeet the elevationFeet to set
     */
    public void setElevationFeet(int elevationFeet) {
        this.elevationFeet = elevationFeet;
    }
    /**
     * @return the mapName
     */
    public String getMapName() {
        return mapName;
    }
    /**
     * @param mapName the mapName to set
     */
    public void setMapName(String mapName) {
        this.mapName = mapName;
    }
    /**
     * @return the createdDate
     */
    public Date getCreatedDate() {
        return createdDate;
    }
    /**
     * @param createdDate the createdDate to set
     */
    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }
    /**
     * @return the modifiedDate
     */
    public Date getModifiedDate() {
        return modifiedDate;
    }
    /**
     * @param modifiedDate the modifiedDate to set
     */
    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }
    /**
     * @return the sortBy
     */
    public SortByType[] getSortBy() {
        return sortBy;
    }
    /**
     * @param sortBy the sortBy to set
     */
    public void setSortBy(SortByType[] sortBy) {
        this.sortBy = sortBy;
    }
    @Override
    public int compareTo(GISData o) {
        /**
         * Make sure to complete this section in such a way that the 
         * type of comparison can easily be changed to factor in the different 
         * types of comparisons you need to make. I've given you a mechanism 
         * in the class to essentially select the comparison type. You can use that 
         * or you could code different methods, call those methods from here 
         * and comment out the methods you won't use. It's up to you.
         */
        return 0;
    }
    @Override 
    public String toString() {
        return String.format("ID: %s\r\nName: %s\r\nClass: %s\r\n");
    }
}

我期望我加载的每个数据实例的输出。虽然这是一个巨大的数据集,但我只是希望能够将我的数据加载到程序中。此外,如果有人对我可以编写的有效排序和搜索数据的方法有任何建议,我将不胜感激。

(我正在使用的数据集:https ://s3.us-east-1.amazonaws.com/blackboard.learn.xythos.prod/5744b9beb8ccb/8090292?response-content-disposition=inline%3B%20filename%2A%3DUTF -8%27%27CA_Features_20190301.txt&response-content-type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190525T170332Z&X-Amz-SignedHeaders=host&X-Amz-Expires=21599&X-Amz-Credential=QIAIL7WQ %2F20190525%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=a0e4ce710ad5f5226b3f60544d897c7bd5cd1da59632e5248655b149ef56f7e3 )

标签: javaarraysobjectarraylist

解决方案


Apache Commons CSV

我让Apache Commons CSV库完成阅读我的文本文件的工作。(注意:JavaDoc 在这里- 他们在主页上的链接已损坏。)

我从CSVFormat.TDF格式定义开始,然后将其更改为期望 VERTICAL BAR (pipe, |) 而不是 Tab 字符作为分隔符。

我使用枚举来命名输入数据的所有字段。但这是可选的,您可以使用字符串名称。

当心浮点类型以double 牺牲准确性来换取执行速度。如果您希望您的号码保持不变,请使用BigDecimal.

通过使用对象而不是原语,我们可以使用 anull来显示您的输入在哪里丢失了数据。

我使用三元运算符来测试 NULL 值。三元组只是一个if-the-else折叠成一行的语句,使用以下语法:

result = test ? valueToUseIfTestIsTrue : valueToUseIfTestIsFalse ; 

示例:如果以米为单位的海拔是一个空字符串,则记录一个 NULL。否则,将传入的字符串解析为Integer对象。

Integer ELEV_IN_M = record.get( FIELD.ELEV_IN_M ).isBlank() ? null : Integer.valueOf( record.get( FIELD.ELEV_IN_M ) );

String::isBlank方法是 Java 11 中的新方法。它测试空字符串或完全由空白字符组成的字符串。String::isEmpty对于早期的 Java,在 Java 6 及更高版本中替换为。您的数据似乎只有空字符串,没有空格,但我没有验证这一观察结果。

跳过 getter/setter 方法。只需使用public成员变量,直到所有其他代码都正常工作,并且直到您有特定理由对访问器方法进行分层。

为了更快地编写此演示代码,我只是按原样复制粘贴了您的数据文件的文件名,全部大写。我没有费心按照规范的 Java 更改为驼峰式。

这是一个完整的工作示例,在一个带有方法演示的大类中main

package work.basil.example;

import org.apache.commons.csv.*;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.math.BigDecimal;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

public class Gis
{
    public enum FIELD
    {
        FEATURE_ID, FEATURE_NAME, FEATURE_CLASS, STATE_ALPHA, STATE_NUMERIC, COUNTY_NAME, COUNTY_NUMERIC, PRIMARY_LAT_DMS, PRIM_LONG_DMS, PRIM_LAT_DEC, PRIM_LONG_DEC, SOURCE_LAT_DMS, SOURCE_LONG_DMS, SOURCE_LAT_DEC, SOURCE_LONG_DEC, ELEV_IN_M, ELEV_IN_FT, MAP_NAME, DATE_CREATED, DATE_EDITED
    }

    public String FEATURE_NAME, FEATURE_CLASS, STATE_ALPHA, STATE_NUMERIC, COUNTY_NAME, COUNTY_NUMERIC, PRIMARY_LAT_DMS, PRIM_LONG_DMS, SOURCE_LAT_DMS, SOURCE_LONG_DMS, MAP_NAME;
    public Integer FEATURE_ID, ELEV_IN_M, ELEV_IN_FT;
    public BigDecimal PRIM_LAT_DEC, PRIM_LONG_DEC, SOURCE_LAT_DEC, SOURCE_LONG_DEC;
    public LocalDate DATE_CREATED, DATE_EDITED;

    // Constructor
    public Gis ( Integer FEATURE_ID , String FEATURE_NAME , String FEATURE_CLASS , String STATE_ALPHA , String STATE_NUMERIC , String COUNTY_NAME , String COUNTY_NUMERIC , String PRIMARY_LAT_DMS , String PRIM_LONG_DMS , BigDecimal PRIM_LAT_DEC , BigDecimal PRIM_LONG_DEC , String SOURCE_LAT_DMS , String SOURCE_LONG_DMS , BigDecimal SOURCE_LAT_DEC , BigDecimal SOURCE_LONG_DEC , Integer ELEV_IN_M , Integer ELEV_IN_FT , String MAP_NAME , LocalDate DATE_CREATED , LocalDate DATE_EDITED )
    {
        Objects.requireNonNull( FEATURE_ID ); // … and so on.
        this.FEATURE_ID = FEATURE_ID;
        this.FEATURE_NAME = FEATURE_NAME;
        this.FEATURE_CLASS = FEATURE_CLASS;
        this.STATE_ALPHA = STATE_ALPHA;
        this.STATE_NUMERIC = STATE_NUMERIC;
        this.COUNTY_NAME = COUNTY_NAME;
        this.COUNTY_NUMERIC = COUNTY_NUMERIC;
        this.PRIMARY_LAT_DMS = PRIMARY_LAT_DMS;
        this.PRIM_LONG_DMS = PRIM_LONG_DMS;
        this.PRIM_LAT_DEC = PRIM_LAT_DEC;
        this.PRIM_LONG_DEC = PRIM_LONG_DEC;
        this.SOURCE_LAT_DMS = SOURCE_LAT_DMS;
        this.SOURCE_LONG_DMS = SOURCE_LONG_DMS;
        this.SOURCE_LAT_DEC = SOURCE_LAT_DEC;
        this.SOURCE_LONG_DEC = SOURCE_LONG_DEC;
        this.ELEV_IN_M = ELEV_IN_M;
        this.ELEV_IN_FT = ELEV_IN_FT;
        this.MAP_NAME = MAP_NAME;
        this.DATE_CREATED = DATE_CREATED;
        this.DATE_EDITED = DATE_EDITED;
    }

    // -------|  Object  |-----------------------

    @Override
    public String toString ()
    {
        return new StringJoiner( " | " , Gis.class.getSimpleName() + "{ " , " }" )
                .add( "FEATURE_ID='" + this.FEATURE_ID + "'" )
                .add( "FEATURE_NAME='" + this.FEATURE_NAME + "'" )
                .toString();
    }

    // -------|  Parsing  |----------------------

    static public List < Gis > parseFile ( final String path )
    {
        ArrayList < Gis > list = new ArrayList <>();
        DateTimeFormatter f = DateTimeFormatter.ofPattern( "MM/dd/uuuu" );
        try
        {
            Reader reader = new FileReader( path );

            CSVFormat format = CSVFormat.TDF.withHeader( Gis.FIELD.class ).withFirstRecordAsHeader().withTrim().withDelimiter( '|' ); // Must pass a `char` to `withDelimiter` not a `String`, so use single-quote not double-quote.
            Iterable < CSVRecord > records = format.parse( reader );
            for ( CSVRecord record : records )
            {
                // FEATURE_ID|FEATURE_NAME|FEATURE_CLASS|STATE_ALPHA|STATE_NUMERIC|COUNTY_NAME|COUNTY_NUMERIC|PRIMARY_LAT_DMS|PRIM_LONG_DMS|PRIM_LAT_DEC|PRIM_LONG_DEC|SOURCE_LAT_DMS|SOURCE_LONG_DMS|SOURCE_LAT_DEC|SOURCE_LONG_DEC|ELEV_IN_M|ELEV_IN_FT|MAP_NAME|DATE_CREATED|DATE_EDITED

                Integer FEATURE_ID = Integer.valueOf( record.get( FIELD.FEATURE_ID ) );
                String FEATURE_NAME = record.get( FIELD.FEATURE_NAME );
                String FEATURE_CLASS = record.get( FIELD.FEATURE_CLASS );
                String STATE_ALPHA = record.get( FIELD.STATE_ALPHA );
                String STATE_NUMERIC = record.get( FIELD.STATE_NUMERIC );
                String COUNTY_NAME = record.get( FIELD.COUNTY_NAME );
                String COUNTY_NUMERIC = record.get( FIELD.COUNTY_NUMERIC );
                String PRIMARY_LAT_DMS = record.get( FIELD.PRIM_LONG_DMS );
                String PRIM_LONG_DMS = record.get( FIELD.PRIM_LONG_DMS );
                BigDecimal PRIM_LAT_DEC = record.get( FIELD.PRIM_LAT_DEC ).isBlank() ? null : new BigDecimal( record.get( FIELD.PRIM_LAT_DEC ) );
                BigDecimal PRIM_LONG_DEC = record.get( FIELD.PRIM_LONG_DEC ).isBlank() ? null : new BigDecimal( record.get( FIELD.PRIM_LONG_DEC ) );
                String SOURCE_LAT_DMS = record.get( FIELD.SOURCE_LAT_DMS );
                String SOURCE_LONG_DMS = record.get( FIELD.SOURCE_LONG_DMS );
                BigDecimal SOURCE_LAT_DEC = record.get( FIELD.SOURCE_LAT_DEC ).isBlank() ? null : new BigDecimal( record.get( FIELD.SOURCE_LAT_DEC ) );
                BigDecimal SOURCE_LONG_DEC = record.get( FIELD.SOURCE_LONG_DEC ).isBlank() ? null : new BigDecimal( record.get( FIELD.SOURCE_LONG_DEC ) );
                Integer ELEV_IN_M = record.get( FIELD.ELEV_IN_M ).isBlank() ? null : Integer.valueOf( record.get( FIELD.ELEV_IN_M ) );
                Integer ELEV_IN_FT = record.get( FIELD.ELEV_IN_FT ).isBlank() ? null : Integer.valueOf( record.get( FIELD.ELEV_IN_FT ) );
                String MAP_NAME = record.get( FIELD.MAP_NAME );
                LocalDate DATE_CREATED = record.get( FIELD.DATE_CREATED ).isBlank() ? null : LocalDate.parse( record.get( FIELD.DATE_CREATED ) , f );
                LocalDate DATE_EDITED = record.get( FIELD.DATE_EDITED ).isBlank() ? null : LocalDate.parse( record.get( FIELD.DATE_EDITED ) , f );

                Gis gis = new Gis( FEATURE_ID , FEATURE_NAME , FEATURE_CLASS , STATE_ALPHA , STATE_NUMERIC , COUNTY_NAME , COUNTY_NUMERIC , PRIMARY_LAT_DMS , PRIM_LONG_DMS , PRIM_LAT_DEC , PRIM_LONG_DEC , SOURCE_LAT_DMS , SOURCE_LONG_DMS , SOURCE_LAT_DEC , SOURCE_LONG_DEC , ELEV_IN_M , ELEV_IN_FT , MAP_NAME , DATE_CREATED , DATE_EDITED );
                list.add( gis );
            }
        } catch ( FileNotFoundException e )
        {
            e.printStackTrace();
        } catch ( IOException e )
        {
            e.printStackTrace();
        }
        list.trimToSize();
        return list;
    }

    // ---------|  Demo (psvm)  |------------------------------------------
    public static void main ( String[] args )
    {
        if ( false ) // Experiment on a small file, a subset of data. If that works, run the huge file.
        {
            String path = "/Users/basilbourque/gis-small.txt";
            List < Gis > list = Gis.parseFile( path );
            System.out.println( "list.size(): " + list.size() );
            System.out.println( "list: " + list );
        } else
        {
            String path = "/Users/basilbourque/gis.txt";
            List < Gis > list = Gis.parseFile( path );
            System.out.println( "list.size(): " + list.size() );
            System.out.println( "list.sublist( 0 , 10 ): " + list.subList( 0 , 10 ) );
            System.out.println( "list.sublist (last 10): " + list.subList( list.size()-10 ,list.size()) );
        }
    }
}

跑的时候。

列表大小():122669

list.sublist( 0 , 10 ): [Gis{ FEATURE_ID='2928' | FEATURE_NAME='Cibola 桥'}, Gis{ FEATURE_ID='6185' | FEATURE_NAME='帝国国家野生动物保护区'}, Gis{ FEATURE_ID='8164' | FEATURE_NAME='莫哈维峡谷'}, Gis{ FEATURE_ID='8174' | FEATURE_NAME='莫哈维谷'}, Gis{ FEATURE_ID='9144' | FEATURE_NAME='Palo Verde Dam' }, Gis{ FEATURE_ID='9146' | FEATURE_NAME='Palo Verde Intake' }, Gis{ FEATURE_ID='9227' | FEATURE_NAME='帕克谷'}, Gis{ FEATURE_ID='12628' | FEATURE_NAME='托波克峡谷'}, Gis{ FEATURE_ID='14114' | FEATURE_NAME='尤马主运河'}, Gis{ FEATURE_ID='22751' | FEATURE_NAME='Cibola 国家野生动物保护区' }]

list.sublist(最后 10 个):[Gis{ FEATURE_ID='27833610' | FEATURE_NAME='海军陆战队新兵仓库邮局'}, Gis{ FEATURE_ID='27833611' | FEATURE_NAME='MCAS 美丽华邮局'}, Gis{ FEATURE_ID='27833612' | FEATURE_NAME='麦考伊山邮局'}, Gis{ FEATURE_ID='27833613' | FEATURE_NAME='NAS 北岛邮局'}, Gis{ FEATURE_ID='27833614' | FEATURE_NAME='帕拉邮局'}, Gis{ FEATURE_ID='27833615' | FEATURE_NAME='Pinon Hills 邮局'}, Gis{ FEATURE_ID='27833616' | FEATURE_NAME='耶尔莫邮局'}, Gis{ FEATURE_ID='27833617' | FEATURE_NAME='联邦科维纳邮局'}, Gis{ FEATURE_ID='27833618' | FEATURE_NAME='蒙塔尔沃邮局'}, Gis{ FEATURE_ID='27833619' | FEATURE_NAME='比佛利山邮局' }]

在实际工作中,我会将解析的东西移到它自己的类中,保留Gis类仅用于数据验证和存储。


推荐阅读